title: Nested copy loop ARM template
body: <p>Trying to create an ARM template with a double copy loop:</p>
  <pre><code>    {
      &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,
      &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
      &quot;parameters&quot;: {
          &quot;privateDnsZones&quot;: {
              &quot;type&quot;: &quot;array&quot;,
              &quot;metadata&quot;: {
                  &quot;description&quot;: &quot;List of private DNS zones to create&quot;
              },
              &quot;allowedValues&quot;: [
                  &quot;privatelink.azure-automation.net&quot;, // Azure Automation  / Webhook,
                  &quot;and more&quot;
              ]
          },
          &quot;virtualNetworkName&quot;: {
              &quot;type&quot;: &quot;string&quot;,
              &quot;metadata&quot;: {
                  &quot;description&quot;: &quot;Name of the Virtual Network to attach the PrivateLink DNS Zones to.&quot;
              }
          },
          &quot;virtualNetworkResourceGroupName&quot;: {
              &quot;type&quot;: &quot;string&quot;,
              &quot;metadata&quot;: {
                  &quot;description&quot;: &quot;Name of the Resource Group containing the Virtual Network.&quot;
              }
          }
      },
      &quot;resources&quot;: [
          {
              &quot;type&quot;: &quot;Microsoft.Network/privateDnsZones&quot;,
              &quot;name&quot;: &quot;[parameters('privateDnsZones')[copyIndex()]]&quot;,
              &quot;apiVersion&quot;: &quot;2020-01-01&quot;,
              &quot;location&quot;: &quot;global&quot;,
              &quot;copy&quot;: {
                  &quot;name&quot;: &quot;zone&quot;,
                  &quot;count&quot;: &quot;[length(parameters('privateDnsZones'))]&quot;
              }
          },
          {
              &quot;type&quot;: &quot;Microsoft.Network/privateDnsZones/virtualNetworkLinks&quot;,
              &quot;name&quot;: &quot;[concat(parameters('privateDnsZones')[copyIndex('link')], '/', parameters('virtualNetworkResourceGroupName'),'-',parameters('virtualNetworkName'))]&quot;,
              &quot;apiVersion&quot;: &quot;2020-06-01&quot;,
              &quot;location&quot;: &quot;global&quot;,
              &quot;copy&quot;: {
                  &quot;name&quot;: &quot;link&quot;,
                  &quot;count&quot;: &quot;[length(parameters('privateDnsZones'))]&quot;
              },
              &quot;dependsOn&quot;: [
                  &quot;zone&quot;
              ],
              &quot;properties&quot;: {
                  &quot;registrationEnabled&quot;: false,
                  &quot;virtualNetwork&quot;: {
                      &quot;id&quot;: &quot;[resourceId(parameters('virtualNetworkResourceGroupName'), 'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]&quot;
                  }
              }
          }
      ]
  }
  </code></pre>
  <p>So far it is going just fine. It deploys the multiple private dns zones as expected.
  Now I want to change the template so that I can deploy multiple zones and also link the zones to multiple vNets.</p>
  <p>Parameter file would looks something like this:</p>
  <pre><code>    {
      &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#&quot;,
      &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,
      &quot;parameters&quot;: {
          &quot;privateDnsZones&quot;: {
              &quot;value&quot;: [
                  &quot;privatelink.blob.core.windows.net&quot;,
                  &quot;privatelink.table.core.windows.net&quot;
              ]
          },
          &quot;virtualNetwork&quot;: {
              &quot;value&quot;: [
                  {
                      &quot;vnetName&quot;: &quot;vnet1&quot;,
                      &quot;resourceGroup&quot;: &quot;vnet1&quot;,
                      &quot;subscriptionId&quot;: &quot;11111111-1111-1111-1111-111111111111&quot;
                  },
                  {
                      &quot;vnetName&quot;: &quot;vnet2&quot;,
                      &quot;resourceGroup&quot;: &quot;vnet2&quot;,
                      &quot;subscriptionId&quot;: &quot;22222222-2222-2222-2222-222222222222&quot;
                  }
              ]
          }
      }
  }
  </code></pre>
  <p>Idea would be that the template loops trough the Pricate DNS Zones, but also through the virtualNetworks. The tricky part for me is that I need the information of both loops in the name of the link.
  Tried multiple things, but ended up with or syntax error within the template or errors during deployment.</p>
  <p>Hopefully someone can give me a push in the right direction...</p>