{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "deploymentContext": { "type": "object" }, "virtualNetworks": { "type": "array" }, "virtualNetworkPeerings": { "type": "array", "defaultValue": [] } }, "variables": { "templateUniqueString": "[uniqueString(concat(string(parameters('deploymentContext')), string(parameters('virtualNetworks')), string(parameters('virtualNetworkPeerings'))))]", "workaround": [ { "name": "workaround", "subscriptionId": "workaround", "resourceGroupName": "workaround", "location": "workaround", "properties": {} } ], "peerings": "[if(greater(length(parameters('virtualNetworkPeerings')), 0), parameters('virtualNetworkPeerings'), variables('workaround'))]" }, "resources": [ { "type": "Microsoft.Resources/deployments", "apiVersion": "2017-05-10", "name": "[concat(parameters('deploymentContext').parentTemplateUniqueString, '-vnet-', copyIndex(), '-', variables('templateUniqueString'))]", "resourceGroup": "[parameters('virtualNetworks')[copyIndex()].resourceGroupName]", "copy": { "name": "virtualNetworks", "count": "[length(parameters('virtualNetworks'))]", "mode": "Parallel" }, "properties": { "mode": "Incremental", "template": { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "variables": {}, "resources": [ { "type": "Microsoft.Network/virtualNetworks", "apiVersion": "2019-04-01", "location": "[parameters('virtualNetworks')[copyIndex()].location]", "name": "[parameters('virtualNetworks')[copyIndex()].name]", "properties": "[parameters('virtualNetworks')[copyIndex()].properties]", "tags": "[parameters('virtualNetworks')[copyIndex()].tags]" } ], "outputs": {} } } }, { "type": "Microsoft.Resources/deployments", "apiVersion": "2017-05-10", "name": "[concat(parameters('deploymentContext').parentTemplateUniqueString, '-vnetPeering-', copyIndex(), '-', variables('templateUniqueString'))]", "condition": "[greater(length(parameters('virtualNetworkPeerings')), 0)]", "resourceGroup": "[variables('peerings')[copyIndex()].resourceGroupName]", "dependsOn": [ "virtualNetworks" ], "copy": { "name": "vnpIterator", "count": "[length(variables('peerings'))]", "mode": "Serial" }, "properties": { "mode": "Incremental", "template": { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": {}, "variables": {}, "resources": [ { "type": "Microsoft.Network/virtualNetworks/virtualNetworkPeerings", "apiVersion": "2019-04-01", "location": "[variables('peerings')[copyIndex()].location]", "name": "[variables('peerings')[copyIndex()].name]", "properties": "[variables('peerings')[copyIndex()].properties]" } ], "outputs": {} } } } ], "outputs": {} }