Examples/AzureIoTDemo/ARMTemplates/azuredeploy.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "automationAccountName": {
            "type": "string",
            "defaultValue": "PSLegoAutomation"
        },
        "iotHubName": {
            "type": "string",
            "minLength": 3,
            "metadata": {
                "description": "Specifies the name of the IoT Hub."
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "Specifies the location for all resources."
            }
        },
        "skuName": {
            "type": "string",
            "defaultValue": "F1",
            "metadata": {
                "description": "Specifies the IotHub SKU."
            }
        },
        "capacityUnits": {
            "type": "int",
            "minValue": 1,
            "defaultValue": 1,
            "metadata": {
                "description": "Specifies the number of provisioned IoT Hub units. Restricted to 1 unit for the F1 SKU. Can be set up to maximum number allowed for subscription."
            }
        }
    },
    "variables": {
        "batch1": {
            "Modules": [
                {
                    "name": "AzureIoT",
                    "moduleURIName": "SHiPS"
                }
            ]
        }
    },
    "resources": [
        {
            "type": "Microsoft.Devices/IotHubs",
            "apiVersion": "2018-04-01",
            "name": "[parameters('iotHubName')]",
            "location": "[parameters('location')]",
            "properties": {
                "operationsMonitoringProperties": {
                    "events": {
                        "None": "None",
                        "Connections": "None",
                        "DeviceTelemetry": "None",
                        "C2DCommands": "None",
                        "DeviceIdentityOperations": "None",
                        "FileUploadOperations": "None",
                        "Routes": "None"
                    }
                },
                "ipFilterRules": [
                ],
                "eventHubEndpoints": {
                    "events": {
                        "retentionTimeInDays": 1,
                        "partitionCount": 2,
                        "partitionIds": [
                            "0",
                            "1"
                        ]
                    },
                    "operationsMonitoringEvents": {
                        "retentionTimeInDays": 1,
                        "partitionCount": 2,
                        "partitionIds": [
                            "0",
                            "1"
                        ]
                    }
                },
                "routing": {
                    "endpoints": {
                        "serviceBusQueues": [
                        ],
                        "serviceBusTopics": [
                        ],
                        "eventHubs": [
                        ],
                        "storageContainers": [
                        ]
                    },
                    "routes": [
                    ],
                    "fallbackRoute": {
                        "name": "$fallback",
                        "source": "DeviceMessages",
                        "condition": "true",
                        "endpointNames": [
                            "events"
                        ],
                        "isEnabled": true
                    }
                },
                "storageEndpoints": {
                    "$default": {
                        "sasTtlAsIso8601": "PT1H",
                        "connectionString": "",
                        "containerName": ""
                    }
                },
                "messagingEndpoints": {
                    "fileNotifications": {
                        "lockDurationAsIso8601": "PT1M",
                        "ttlAsIso8601": "PT1H",
                        "maxDeliveryCount": 10
                    }
                },
                "enableFileUploadNotifications": false,
                "cloudToDevice": {
                    "maxDeliveryCount": 10,
                    "defaultTtlAsIso8601": "PT1H",
                    "feedback": {
                        "lockDurationAsIso8601": "PT60S",
                        "ttlAsIso8601": "PT1H",
                        "maxDeliveryCount": 10
                    }
                },
                "features": "None"
            },
            "sku": {
                "name": "[parameters('skuName')]",
                "capacity": "[parameters('capacityUnits')]"
            }
        },
        {
            "name": "[parameters('automationAccountName')]",
            "type": "Microsoft.Automation/automationAccounts",
            "apiVersion": "2015-10-31",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[parameters('iotHubName')]"
            ],
            "properties": {
                "sku": {
                    "name": "Free"
                },
                "resources": [
                    {
                        "name": "AzureIotConnectionString",
                        "type": "variables",
                        "apiVersion": "2015-10-31",
                        "dependsOn": [
                            "[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
                        ],
                        "tags": {
                        },
                        "properties": {
                            "description": "Iot Connection String",
                            "isEncrypted": false,
                            "type": "string",
                            "value": "[listKeys(resourceId('Microsoft.Devices/IotHubs/Iothubkeys', parameters('iotHubName'), 'iothubowner'), '2016-02-03').primaryKey]"
                        }
                    },
                    {
                        "name": "[concat(parameters('automationAccountName'), '/', variables('batch1').Modules[copyIndex()].Name)]",
                        "type": "Microsoft.Automation/automationAccounts/modules",
                        "apiVersion": "2015-10-31",
                        "location": "[parameters('location')]",
                        "dependsOn": [
                            "[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]"
                        ],
                        "copy": {
                            "name": "solutionCopy",
                            "count": "[length(variables('batch1').Modules)]",
                            "mode": "Serial"
                        },
                        "properties": {
                            "isGlobal": false,
                            "sizeInBytes": 0,
                            "contentLink": {
                                "uri": "[concat('https://www.powershellgallery.com/api/v2/package/', variables('batch1').Modules[copyIndex()].moduleURIName)]"
                            }
                        }
                    },
                    {
                        "name": "New-RobotFlowIoT",
                        "type": "runbooks",
                        "apiVersion": "2015-10-31",
                        "location": "[parameters('location')]",
                        "dependsOn": [
                            "[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'))]",
                            "[concat('Microsoft.Automation/automationAccounts/', parameters('automationAccountName'), '/variables/AzureIotConnectionString')]"
                        ],
                        "tags": {
                        },
                        "properties": {
                            "runbookType": "PowerShell",
                            "description": "Made by @JakobGSvendsen",
                            "publishContentLink": {
                                "uri": "https://raw.githubusercontent.com/JakobGSvendsen/PSLegoEV3/master/PSLegoEV3WindowsPowerShell/Examples/AzureIoTDemo/New-RobotFlowIoT.ps1",
                                "version": "1.0.0.1"
                            }
                        }
 
                    }
                ]
            }
        }
    ],
    "outputs": {
        "iotHubKeys": {
            "value": "[listKeys(resourceId('Microsoft.Devices/iotHubs', parameters('iotHubName')), '2018-04-01')]",
            "type": "object"
        },
        "iotHubKeys2": {
            "value": "[take(array(listKeys(resourceId('Microsoft.Devices/iotHubs', parameters('iotHubName')), '2018-04-01')),0)]",
            "type": "string"
        }
    }
}