Here is how you can use a parameters
value to select the property of an object in the variables.
"value": "[variables('objects')[parameters('propertyName')].color]"
A complete example:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"propertyName": {
"type": "string"
}
},
"variables": {
"objects": {
"property0": {
"color": "red"
},
"property1": {
"color": "green"
},
"property2": {
"color": "blue"
}
}
},
"resources": [],
"outputs": {
"messageOutObject": {
"type": "object",
"value": "[variables('objects')]"
},
"messageOutObjectProperty": {
"type": "string",
"value": "[variables('objects')[parameters('propertyName')].color]"
}
}
}
Then you can pick the different properties by passing in different parameter values. For example:
New-AzResourceGroupDeployment -ResourceGroupName 'DeleteMe20190605' -TemplateFile .\azuredeploy.json -TemplateParameterObject @{propertyName = 'property1'}
OR
New-AzResourceGroupDeployment -ResourceGroupName 'DeleteMe20190605' -TemplateFile .\azuredeploy.json -TemplateParameterObject @{propertyName = 'property2'}
Results:
