In an ARM Template with a following parameter:
{
"$schema": "...",
"contentVersion": "1.0.0.0",
"parameters": {
...
"SkipThisComponent": {
"type": "bool"
...
}
how would one use it inside a resource condition?
"resources": [
{
"apiVersion": "...",
"name": "...",
"type": "...",
"condition": "[???]",
I tried out several approaches, but it seems that equals
supports only [int, string, array, or object], if
needs both the condition and values to match it to etc. I didn't find a nice clean approach, all seem to be workarounds with casting...
Parameters. In the parameters section of the template, you specify which values you can input when deploying the resources. You're limited to 256 parameters in a template. You can reduce the number of parameters by using objects that contain multiple properties.
In the file, you provide the parameter values you want to pass in during deployment. Within the parameter file, you provide values for the parameters in your template. The name of each parameter in your parameter file needs to match the name of a parameter in your template.
Parameters will prompt the user for the values unless they are hardcoded. Variables are used to have a single point where information is declared rather than repeating that value all the way through a template.
The basic syntax of the Azure Resource Manager template (ARM template) is JavaScript Object Notation (JSON). However, you can use expressions to extend the JSON values available within the template.
You can just use the variable within the condition:
"condition" : "[not(variables('SkipThisComponent'))]"
"condition" : "[variables('CreateThisComponent')]"
Logic Functions Ref.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With