I'm trying to create a conditional resource template. The devel environment is not as beefy as the production environment and I've been successful in doing this for the most part. However, I can't seem to get nested resources right.
Here's a snippet from my ARM template:
"webApp-resources": "[variables(concat('webApp-', parameters('env'), '-resources'))]",
"webApp-dev-resources": [],
"webApp-prod-resources": [
{
"name": "staging",
"type": "Microsoft.Web/sites/slots",
"location": "[resourceGroup().location]",
"apiVersion": "2015-08-01",
"dependsOn": [
"[resourceId('Microsoft.Web/sites', variables('webApp-name'))]"
]
}
],
The idea is simple, the resources variable is composed using the env parameter. The env parameter can be either dev or prod and while this works, I get the following error when I try to deploy this template.
{
"name": "[variables('webApp-name')]",
"type": "Microsoft.Web/sites",
...
"resources": "[variables('webApp-resources')]" // <- culprit!
},
The request content was invalid and could not be deserialized: 'Error converting value "[variables('webApp-resources')]" to type 'Microsoft.WindowsAzure.ResourceStack.Frontdoor.Templates.Schema.TemplateResource[]'. Path 'properties.template.resources[1].resources', line 195, position 64.'
I've also tried moving the resource into a variable and referencing the variable in a similar conditional manner, very similar to how we would do nested template linking but without the template linking.
resources: [
"[variables('webApp-resource')]" // <- this doesn't work!
]
This resulted in a similar error but different error if I recalled correctly.
From this I've concluded that ARM template syntax is not simply find and replace which I think is bad because it does make it harder to reason about what works and what doesn't. Because if it was, this would have resulted in a valid template that would work. Which I've verified by pasting the correct value into the resources section.
Has anyone had similar problems, how did you work around the issue?
variableinstead of aresource? I'm pretty sure you can't do that, but you can create slots conditionally - 4c74356b41