cicorias
6/7/2017 - 7:38 PM

DeployEventHub

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "eventHubName": {
            "type": "string"
        }
    },
    "variables": {
        "resourceLocation": "[resourceGroup().location]",
        "eventHubName": "[parameters('eventHubName')]",
        "eventHubs": [
            "docHub",
            "activityHub",
            "sqlHub"
        ],
        "consumerGroups": [
            "docHub/hashing-consumer",
            "activityHub/dlt-consumer",
            "activityHub/dlt-api-consumer",
            "sqlHub/sql-consumer"
        ],
        "eventHubKeys": [
            {
                "name": "ReadWrite",
                "rights": [
                    "Listen",
                    "Send"
                ]
            }
        ]
    },
    "resources": [
        {
            "type": "Microsoft.EventHub/namespaces",
            "sku": {
                "name": "Standard",
                "tier": "Standard"
            },
            "kind": "EventHub",
            "name": "[variables('eventHubName')]",
            "apiVersion": "2015-08-01",
            "location": "[variables('resourceLocation')]",
            "properties": {},
            "tags": {},
            "dependsOn": []
        },
        {
            "type": "Microsoft.EventHub/namespaces/eventhubs",
            "name": "[concat(variables('eventHubName'), '/', variables('eventHubs')[copyIndex()])]",
            "apiVersion": "2015-08-01",
            "copy": {
                "name": "eventHubLoop",
                "count": "[length(variables('eventHubs'))]"
            },
            "location": "[variables('resourceLocation')]",
            "properties": {
                "messageRetentionInDays": 1,
                "partitionCount": 2,
                "partitionIds": [
                    0,
                    1
                ]
            },
            "dependsOn": [
                "[variables('eventHubName')]"
            ]
        },
        {
            "type": "Microsoft.EventHub/namespaces/eventhubs/consumergroups",
            "name": "[concat(variables('eventHubName'), '/', variables('consumerGroups')[copyIndex()])]",
            "apiVersion": "2015-08-01",
            "copy": {
                "name": "consumerGroups",
                "count": "[length(variables('consumerGroups'))]"
            },
            "location": "[variables('resourceLocation')]",
            "properties": {},
            "dependsOn": [
                "[variables('eventHubName')]",
                "eventHubLoop"
            ]
        },
        {
            "apiVersion": "2015-08-01",
            "name": "[concat(variables('eventHubName'), '/', variables('eventHubKeys')[copyIndex()].name)]",
            "type": "Microsoft.EventHub/namespaces/AuthorizationRules",
            "copy": {
                "name": "eventHubKeyLoop",
                "count": "[length(variables('eventHubKeys'))]"
            },
            "location": "[resourceGroup().location]",
            "properties": {
                "rights": "[variables('eventHubKeys')[copyIndex()].rights]"
            },
            "dependsOn": [
                "[variables('eventHubName')]"
            ]
        }
    ],
    "outputs": {
        "Result": {
            "type": "object",
            "value": {
                "name": "[variables('eventHubName')]",
                "endPoint": "[reference(variables('eventHubName')).serviceBusEndpoint]",
                "readWriteKey": "[listKeys(resourceId('Microsoft.EventHub/namespaces/authorizationRules', variables('eventHubName'), variables('eventHubKeys')[0].name), '2015-08-01').primaryKey]"
            }
        }
    }
}