title: How to create multiple Service Bus topics using ARM template?
body: <p>I've looked at the <a href="https://github.com/Azure/azure-quickstart-templates/tree/master/101-servicebus-topic" rel="nofollow">https://github.com/Azure/azure-quickstart-templates/tree/master/101-servicebus-topic</a> example. Now I'm trying to figure out how to create several topics when running the deploy script using nested resource looping (<a href="https://azure.microsoft.com/en-us/documentation/articles/resource-group-create-multiple/#looping-on-a-nested-resource" rel="nofollow">https://azure.microsoft.com/en-us/documentation/articles/resource-group-create-multiple/#looping-on-a-nested-resource</a>).</p>
  
  <p>It would be nice to just define an array in the value for <code>serviceBusTopicName</code> and then somehow creating topics by looping through it, instead of doing it manually.</p>
  
  <p>I am getting the following error when trying to deploy.</p>
  
  <pre><code> Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The template resource '[parameters('serviceBusTopicName')[copyIndex()]]' at line '72' column '14' is not valid.
   Copying nested resources is not supported. Please see https://aka.ms/arm-copy/#looping-on-a-nested-resource for usage details.'.
  </code></pre>
  
  <p>This is the <code>template.json</code> that I have tried to get to work.</p>
  
  <pre><code>  "parameters": {
  "serviceBusNamespaceName": {
    "type": "string",
    "metadata": {
      "description": "Name of the Service Bus namespace"
    }
  },
  "serviceBusTopicName": {
    "type": "array",
    "metadata": {
      "description": "Name of the Topic"
    }
  },
  "serviceBusApiVersion": {
    "type": "string",
    "defaultValue": "2015-08-01",
    "metadata": {
      "description": "Service Bus ApiVersion used by the template"
    },
    "resources": [
  {
    "apiVersion": "[variables('sbVersion')]",
    "name": "[parameters('serviceBusNamespaceName')]",
    "type": "Microsoft.ServiceBus/Namespaces",
    "location": "[variables('location')]",
    "kind": "Messaging",
    "sku": {
      "name": "StandardSku",
      "tier": "Standard"
    },
    "resources": [
      {
        "apiVersion": "[variables('sbVersion')]",
        "name": "[parameters('serviceBusTopicName')]",
        "type": "Topics",
        "dependsOn": [
          "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespaceName'))]"
        ],
        "properties": {
          "path": "[parameters('serviceBusTopicName')]"
        },
        "copy": {
          "name": "datasetcopy",
          "count": "[length(parameters('serviceBusTopicName'))]"
        }
      }
    ]
  },
  </code></pre>
  
  <p><code>parameters.json</code></p>
  
  <pre><code>{"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
      "serviceBusNamespaceName": {
          "value": "ServiceBus"
      },
    "serviceBusTopicName": {
      "value": [
        "Person",
        "Stadium",
        "Team"
      ]
    },
      "serviceBusApiVersion": {
          "value": "2015-08-01"
      }
  }
  </code></pre>