I have a variable in a template that holds a number of entries that will specify the value in my template. By this I mean I have
"ipSecurityRestrictions" : {
"denyAllInbound":
[
{
"ipAddress": "0.0.0.0/0",
"action": "Deny",
"priority": 100,
"name": "Deny All Inbound"
}
],
"allowAppGatewayOnly":
[
{
"vnetSubnetResourceId": "[variables('appGatewaySubnet')]",
"action": "allow",
"priority": 100,
"name": "Allow App Gateway"
}
]
}
}
I currently use a simple if function to determine which to use based on a parameter (it's actually a little more complex than that but this is enough for the question.) So at the moment I have something like
[if (equals(parameters('a'), 'allowAppGatewayOnly'), variables('ipSecurityRestrictions').allowAppGatewayOnly, variables('ipSecurityRestrictions').denyAllInbound)]
which quite happily works. However, I want to add another entry to the variable and I don't like the idea of having an if chain in there, it's going to get ugly very soon.
So I was trying various ways of using indirection based on the value of the parameter (and all of this is inside a copy loop and different entries in the parameter array could have different entries).
I have tried things like
"[variables('ipSecurityRestrictions')[parameters('appservices')[copyIndex()].ipSecurityRestrictions]]"
but the fact that I'm asking means it didn't work. [edit: it does actually work - if the parameter value is correct that is and doesn't have a stray single quote in it!]
Is it possible to do this in ARM templates or am I stuck with nested if functions calls?
Thanks