Created
March 6, 2020 15:39
-
-
Save Nomenator/2a269044175385f0bb383e5cc66f6a57 to your computer and use it in GitHub Desktop.
Deploy multiple resource grops in Azure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"rgNames": { | |
"type": "array" | |
}, | |
"rgLocation": { | |
"type": "string" | |
} | |
}, | |
"variables": {}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Resources/resourceGroups", | |
"apiVersion": "2018-05-01", | |
"location": "[parameters('rgLocation')]", | |
"name": "[parameters('rgNames')[copyIndex()]]", | |
"copy": { | |
"name": "rgCopy", | |
"count": "[length(parameters('rgNames'))]" | |
} | |
} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"rgNames": { | |
"value": [ | |
"group1", | |
"group2", | |
"group3", | |
"group4" | |
] | |
}, | |
"rgLocation": { | |
"value": "eastus" | |
} | |
} | |
} |
As noted above, the problem is solved by providing the proper command syntax. The correct command invocation to deploy resources at subscription level is as follows: new-AzSubscriptionDeployment -Name <name-of-your-choice> -Location <locationCode> -TemplateFile <path-to-file> -TemplateParameterFile <path-to-another-file>
On a side note, it's curious that the template file is still being read with the -TemplateUri
command, as shown by the proper expectation of rgNames
parameter value, but the parameter file is not being read with the -TemplateParameterUri
, parameter.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Nomenator
If anyone sees this in the future, when dealing with local files, you have to use the
TemplateFile
andTemplateParameterFile
parameter. Not theUri
kind.I'll see if we can bring this feedback to the product group managing that cmdlet.