Update object value #14585
Replies: 2 comments
-
Hey @kamfaima, you are not out of your mind 😄. I think this use-case suits very well with the lambda expression function Let me know here if you need any help or need to understand how map works! |
Beta Was this translation helpful? Give feedback.
-
Sorry for the long delay in getting back to this thread, but I finally got this all done so here's the write-up! It did do my head in with the layers of inception involved and a bit of Bicep learning on the side! As an example, I didn't realise or just plain forgot that I could define/create objects within other function calls. So my logic to tackle this was to start working from the innermost element, i.e. the object that contains the actual IP Group resources, then work back to the outermost element. Kinda like a loop in a loop inception. I had to firstly work out how to retrieve the resource IDs of the IPGs and pass it back up the chain, so that's the order I'll document it here too. I actually did start using
|
Beta Was this translation helpful? Give feedback.
-
Maybe I'm flogging a dead horse here but I was just wondering if there is a way to update the value of an object's property, then pass the entire object to the suitable resource provider or module for processing?
Basically, I want to be able to convert a friendly name for a resource into the (unfriendly) resource ID name for a resource. In my scenario, I have an array of AzFw rule collection groups (RCG) objects. Each RCG contains one or more rule collections (RC). Within a RC can exist one or more rules. A rule may have a
sourceIpGroups
ordestinationIpGroups
property defined. Both these properties are an array of resourceId strings of the IP Groups.An example structure of this is:
Currently, when we author the
.bicepparam
file to feed into our deployment, we need to use the resourceId of the IPG. While the resourceId is somewhat predictable it's still a pain to browse around the portal to get them. I was wondering if we could just use the (short) resource name and have some logic (Bicep, pwsh, magic fairy dust) to convert them into the longer resourceId names that ARM is expecting.I tried writing modules to do some basic parsing and I had some luck in replacing the short resource name with the resourceId instead. But now I'm stumped as to how to update the object's value, if even possible, then recursively pass the object back up the tree. THEN pass the updated object to the resource provider to deploy the AzFw rule collection group itself. The property is just so deeply nested and iterating over arrays where there can be many elements, then somehow merging the results back together again is doing my head in.
Any thoughts on this? Happy to be told I'm out of my mind of course!
Beta Was this translation helpful? Give feedback.
All reactions