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 on 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 starts 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

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 on the conditions we match on.

Read More »

Arinco trades as Arinco (VIC) Pty Ltd
and Arinco (NSW) Pty Ltd

All Rights Reserved

 

Level 9, 360 Collins Street, 
Melbourne VIC 3000

Level 2, 24 Campbell St,
Sydney NSW 2000

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.