Repository navigation
Conditionally include a property #1729
|
I have a case where I want to conditionally omit a property for a resource. I'd like to have that property set to false in certain conditions, but the property does not accept it. If it's present it needs to be true. If I want to set it to false, it has to be omitted altogether. I am aware we can conditionally set a value for a property, but that does not apply in this case. Is there a way to do this in bicep (or ARM)? |
Replies: 6 comments 5 replies
|
Have you tried setting the value to |
|
Michele Bartolucci (@mickybar) a lot of the tricks in ARM still work here, for instance using json('null') for complex object properties, or just '' for strings. See my fortigate templte for a lot of example of conditional properties and settings/"knobs" |
|
Seeing the loading error on the Azure/Bicep thread reminded me how fragile the preview pane can be when testing conditional property inclusions, nested modules expecting a fully resolved object. In practice, treating the template like a well‑structured dataset—much like consulting Dade property data for accurate cross‑references—helps you validate defaults before the deployment engine evaluates them. If the page still won’t render, a hard refresh or clearing the cache usually forces the Bicep compiler to reload the latest JSON, letting you verify the conditional logic now resolves without errors. |
|
I noticed the page repeatedly throws the “error while loading” message, which usually means the Bicep compiler didn’t receive the full JSON payload. In those cases I treat the problem like I would when validating Wakulla property values verify the source data before the engine processes it. Reloading the file, clearing the browser cache, and running az bicep build with the --no-restore flag normally resolves the conditional property inclusion glitch. |
Have you tried setting the value to
nullwhen the condition is false? This typically gets handled by the resource as if the property was not declared.