Blogs

Multiple conditions for Bicep resource deployments

After working with Bicep templates we have discovered a useful mechanism, multiple conditions. Multiple conditions provide ways to be more specific in the way we perform conditional deployments and enable us to have more control over the conditions we match on.

Multiple Condition Configuration

To perform multiple conditions in Bicep resource deployments the following needs to be done:

  • Multiple conditions act the same as normal conditions, and first start with an if statement e.g.
resource lock 'Microsoft.Authorization/locks@2017-04-01' = if (lockName != '') {
   name: lockName
   properties: {
       ..
   }
}
  • The difference comes when you want to add another condition. All you need to add is the following comparison operator “&&” e.g.
resource lock 'Microsoft.Authorization/locks@2017-04-01' = if (lockName != '' && resourcelock != 'None') {
    name: lockName
    properties: {
        ..
    }
}

Conclusion

In this blog post, we looked at how to configure multiple conditions for Bicep resource deployments and discussed the benefits it provides. Hopefully you have found this post informative, if you have other bicep tips and tricks let us know and don’t be afraid to share your thoughts.

[mailpoet_form id="1"]

Other Recent Blogs

Level 9, 360 Collins Street, 
Melbourne VIC 3000

Level 2, 24 Campbell St,
Sydney NSW 2000

200 Adelaide St,
Brisbane QLD 4000

191 St Georges Terrace
Perth WA 6000

Level 10, 41 Shortland Street
Auckland

Part of

Arinco trades as Arinco (VIC) Pty Ltd and Arinco (NSW) Pty Ltd. © 2023 All Rights Reserved Arinco™ | Privacy Policy
Arinco acknowledges the Traditional Owners of the land on which our offices are situated, and pay our respects to their Elders past, present and emerging.

Get started on the right path to cloud success today. Our Crew are standing by to answer your questions and get you up and running.