Reputation: 53
I have a arm template that i'm trying to apply regional conditions to. Like if the Region variable equals EUW then use variable westeurope. Can this be done as an array in the parameters or should this be a variable array with if statements?
I have seen on other threads that ARM templates are really more of an if/else statement instead of if/ifelse/else.
Classic example:
"availabilitySet": "[if(equals(parameters('production'), 'Yes'), variables('availabilitySetId'), json('null'))]",
I'm looking for something like this:
"parameters": {
"Region": {
"type": "string",
"defaultValue": "USSC",
"allowedValues": [
"AIE",
"BRS",
"EUW",
"USSC"
],
"metadata": {
"description": "Select Region"
}
}
},
"variables": {
"regionReference": {
"eastasia": "[if(equals(parameters('Region'), 'AIE')],
"brazilsouth": "[if(equals(parameters('Region'), 'BRS')],
"westeurope": "[if(equals(parameters('Region'), 'EUW')],
"southcentral": "[if(equals(parameters('Region'), 'USSC')],
}
}
Please forgive me for butchering that in advance. I also considered condition statements, but haven't gotten that to work either.
Upvotes: 1
Views: 454
Reputation: 72171
you can just do this:
"regionReference": {
"AIE": "eastasia",
"BRS": "brazilsouth",
"EUW": "westeurope",
"USSC": "southcentral"
}
and then you can reference which region you've chosen:
"location": "[variables('regionReference')[parameters('Region')])]"
Although, I dont see why are you making your life harder in here for no real reason
Upvotes: 2