I'm trying to set a variable in the variables section of an ARM template using the if function.
in the parameter section I've definded a parameter that is been filled by a parameter file. let's call it condition:
"condition": {
"type": "bool",
"defaultValue": false}
now in the variables section I would like to define a variable that if condition is true then var = ["1","2","3"] else var = [] an empty array.
I've tried:
"var" : "[if(parameters('condition'),[\"1\",\"2\",\"3\"],[])]"
"var" : "[if(parameters('condition'),['1','2','3'],[])]"
"var" : "[if(parameters('condition'),array(['1','2','3']),array([]))]"
all with the same result expected token 'Identifier' and actual 'LeftSquareBracket'
error thrown.
of course I can solve it in a similar way to:
"var0" : ["1","2","3"],
"var1" : [],
"var" : "[if(parameters('condition'),variables('var0'),variables('var1')]"
but that would lead to two dummy variables and an uglier code, and I would really like to avoid it.
trying to deploy from azure CLI.
It is surly a syntax error but I just can't figure it out.
Thanks in advance for your help!