Loop dictionary object conditionally #7398
-
Hi all, Bit stuck with this one as my condition appears to set both properties to the same value but i cant work out why it is doing this. I am aware there is another approach for additionalLocations but i am using the dictionary objects for other resource types also so is more efficient the have all location information in one object. I am trying to iterate through an object but omit the value 'primaryLocation':
This is the property code but it still includes the value primaryLocation when run:
Any pointers / ideas would be a great help |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
I would recommend to just use outputs to evaluate the objects or array data that you have. e,g, output info array = items(parLocationObject) provides [
{
"key": "location2",
"value": {
"location": "ukwest",
"vnetAddressPrefix": "10.1.0.0/16",
"subnets": [
{
"name": "snet-appGateway",
"addressPrefix": "10.1.0.0/24",
"nsgName": "nsg-appgateway"
},
{
"name": "snet-apim",
"addressPrefix": "10.1.1.0/24",
"nsgName": "nsg-apim"
}
]
}
},
{
"key": "primaryLocation",
"value": {
"location": "uksouth",
"vnetAddressPrefix": "10.0.0.0/16",
"subnets": [
{
"name": "snet-appGateway",
"addressPrefix": "10.0.0.0/24",
"nsgName": "nsg-appgateway"
},
{
"name": "snet-apim",
"addressPrefix": "10.0.1.0/24",
"nsgName": "nsg-apim"
}
]
}
}
] Notice the key and value properties. |
Beta Was this translation helpful? Give feedback.
-
Ah I see, thank you. I will review and feedback 👍 |
Beta Was this translation helpful? Give feedback.
-
@brwilkinson had a look at this but the API-M module must be called anyway so i cant use a 'if' statement at the module level. I need to re-iterate through AdditionalLocations as its a property of the API-M. I tried using if at the property level but it wont let me. main.bicep (snipped)
apim.bicep (snipped)
Apologies if i am missing what you are suggesting in your work around. |
Beta Was this translation helpful? Give feedback.
I would recommend to just use outputs to evaluate the objects or array data that you have.
e,g,
provides