I'm building an ARM(Azure Resource Manager) template to create multiple resources of the same type. Let's say metric alerts for SQL servers. I have:
Essentially, I need a total of 180 resources. Is there any way how I can build and with all possible combinations of these variables. Ie for each of the servers, I need to monitor 3 metrics where each could trigger 3 possible alerts levels depending on the metric levels.
Naturally, I thought about a Cartesian product of these arrays and then a copy
loop over it to fill the template attributes. However, it doesn't look like ARM supports this.
Is it the point where instead of using ARM I should think about writing a code-generator to create a template instead of trying to bend ARM json?
Regarding the issue, you can add the copy
element to the resources section of your template. After doing that, you can dynamically set the number of resources to deploy. For more details, please refer to here and here .
For example
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"org": {
"type": "array",
"defaultValue": [
"contoso",
"fabrikam",
"coho"
]
}
},
"resources": [
{
"apiVersion": "2017-06-01",
"type": "Microsoft.Storage/storageAccounts",
"name": "[concat(parameters('org')[copyIndex()], uniqueString(resourceGroup().id))]",
"location": "[resourceGroup().location]",
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {},
"copy": {
"name": "storagecopy",
"count": "[length(parameters('org'))]"
}
}
],
"outputs": {}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.