Forum Discussion
vigneshkrcegmailcom
Dec 02, 2020Brass Contributor
Resource Group Creation
Hi Stephan,
Can you please help me to create Multiple RG with TAG's for each RG.
The script i am trying is given below but it is throwing error.
Ultimate aim is to create Multiple RG's with TAG's
Template File i am using is :
{
"contentVersion": "1.0.0.0",
"parameters": {
"rgName": {
"type": "array"
},
"tags": {
"type": "object",
"defaultValue": {}
}
},
"variables": {},
"resources": [
{
"copy": {
"name": "RGLoop",
"count": "[length(parameters('rgName'))]"
},
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2019-10-01",
"name": "[parameters('rgName')[copyIndex('RGLoop')].Name]",
"location": "eastus",
"tags": "[parameters('tags')[copyIndex('RGLoop')].tags]",
"properties": {}
}
],
"outputs": {}
}
==============================
Paramater is given below:
{
"contentVersion": "1.0.0.0",
"parameters": {
"rgname": {
"value": [
{
"name": "TestRG"
}
]
},
"tags": {
"value": [
{
"Environment": "Test",
"Team": "skg",
"Application": "SKG",
"Business Unit": "non-production",
"POC": "Vignesh",
"ManagedBy": "Own"
}
]
}
}
}
=========================================
Error I am Getting is:
There were errors in your deployment. Error code: InvalidTemplate.
##[error]Deployment template validation failed: 'Template parameter JToken type is not valid. Expected 'Object'. Actual 'Array'. Please see https://aka.ms/resource-manager-parameter-files for usage details.'.
##[warning]Validation errors were found in the Azure Resource Manager template. This can potentially cause template deployment to fail. Task failed while creating or updating the template deployment.. Please follow https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax
Starting Deployment.
Deployment name is Deploy-RG
There were errors in your deployment. Error code: InvalidTemplate.
##[error]Deployment template validation failed: 'Template parameter JToken type is not valid. Expected 'Object'. Actual 'Array'. Please see https://aka.ms/resource-manager-parameter-files for usage details.'.
##[error]Check out the troubleshooting guide to see if your issue is addressed: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment...
##[error]Task failed while creating or updating the template deployment.
Finishing: ARM Template deployment: Resource Group
Can you help me to fix this.
Regards,
Vignesh
- michaelelleby123Copper Contributor
vigneshkrcegmailcomThe line "tags": "[parameters('tags')[copyIndex('RGLoop')].tags]", is wrong. It should be:
"tags": "[parameters('tags')[copyIndex('RGLoop')]]",