For my Azure ARM templates, I want to conditionally add an extra NSG rule. If parameter is true, append extra rule to the "securityRules" array. How do I efficiently go about this? I can't use the "condition" properties for nested objects. Creating two resources seems clunky.
This API version corresponds to a version of REST API operations that are released by the resource provider (Microsoft.Compute/virtualMachines is the resource provider and namespace for virtual machines, Microsoft.Storage/storageAccounts is the resource provider and namespace for storage and storage accounts - as ...
A nested template is just basically one template within another. The advantage of a nested template is that you can go ahead and deploy resources across resource groups.
To deploy complex solutions, you can break your Azure Resource Manager template (ARM template) into many related templates, and then deploy them together through a main template. The related templates can be separate files or template syntax that is embedded within the main template.
Depending on a condition, you would like to add an additional (string) value to an existing json array. This can be done via the concat function. In order to concat an array and a string value, the string value will need to be transformed into an array too. When the condition is true, the two arrays can be concatenated. When the condition is false, you can concatenate the existing string with an empty array.
"[concat( parameters('existingArray'), if( parameters('condition'), array('Cc'), variables('emptyArray')) )]"
Assuming the orriginal array is: ["Aa", "Bb"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With