Hi I have an ARM template for create a ServiceBus with its topics and subscriptions. But I can only accomplish 1 topic - 1 subscription because I cannot make a nested loop to create many subscriptions per topic.
I wish I could execute a template like this:
params:
{
"serviceBusName": "mybus",
"topics":
[
{
"topicName": "mytopic1",
"subscriptions": [ "mysubscription1", "mysubscription2"]
},
{
"topicName": "mytopic2",
"subscriptions": [ "mysubscription1"]
}
]
}
This is my actual template:
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"ServiceBusNamespaceName": {
"type": "string"
},
"ServiceBusSku": {
"type": "string",
"allowedValues": [
"Basic",
"Standard"
],
"defaultValue": "Standard"
},
"ServiceBusSmallSizeTopicInMb": {
"type": "int",
"defaultValue": 1024
},
"ServiceBusMaxSizeTopicInMb": {
"type": "int",
"defaultValue": 1024
},
"Topics": {
"type": "array"
}
},
"variables": {
"DefaultSASKeyName": "RootManageSharedAccessKey",
"DefaultAuthRuleResourceId": "[resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('ServiceBusNamespaceName'), variables('DefaultSASKeyName'))]",
"SbVersion": "2017-04-01"
},
"resources": [
{
"apiVersion": "2017-04-01",
"name": "[parameters('ServiceBusNamespaceName')]",
"type": "Microsoft.ServiceBus/namespaces",
"location": "[resourceGroup().location]",
"sku": {
"name": "[parameters('ServiceBusSku')]"
},
"tags": {
"displayName": "ServiceBus"
}
},
{
"copy": {
"name": "topics",
"count": "[length(parameters('Topics'))]"
},
"type": "Microsoft.ServiceBus/namespaces/topics",
"name": "[concat(parameters('ServiceBusNamespaceName'), '/', parameters('Topics')[copyIndex()].topic)]",
"apiVersion": "2017-04-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"defaultMessageTimeToLive": "P1D",
"maxSizeInMegabytes": "[parameters('ServiceBusMaxSizeTopicInMb')]",
"requiresDuplicateDetection": false,
"duplicateDetectionHistoryTimeWindow": "PT10M",
"enableBatchedOperations": true,
"status": "Active",
"supportOrdering": true,
"autoDeleteOnIdle": "P10675199DT2H48M5.4775807S",
"enablePartitioning": false,
"enableExpress": false
},
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('ServiceBusNamespaceName'))]"
],
"resources": [
{
"apiVersion": "[variables('sbVersion')]",
"name": "[parameters('Topics')[copyIndex()].subscription]",
"type": "Subscriptions",
"dependsOn": [
"[parameters('Topics')[copyIndex()].topic]"
],
"properties": {
"lockDuration": "PT1M",
"requiresSession": "false",
"defaultMessageTimeToLive": "P7D",
"deadLetteringOnMessageExpiration": "false",
"maxDeliveryCount": "2",
"enableBatchedOperations": "true",
"autoDeleteOnIdle": "P7D"
}
}
]
}
],
"outputs": {
"NamespaceDefaultConnectionString": {
"type": "string",
"value": "[listkeys(variables('DefaultAuthRuleResourceId'), variables('SbVersion')).primaryConnectionString]"
},
"DefaultSharedAccessPolicyPrimaryKey": {
"type": "string",
"value": "[listkeys(variables('DefaultAuthRuleResourceId'), variables('SbVersion')).primaryKey]"
}
}
}
And an example of the params json for the actual template:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"ServiceBusNamespaceName": {
"value": "mybus"
},
"ServiceBusSku": {
"value": "Standard"
},
"Topics ": {
"value": [
{
"topic": "mytopic1",
"subscription": "mysubscription1"
},
{
"topic": "mytopic2",
"subscription": "mysubscription1"
}
]
}
}
}