Azure Bicep: ARM Templates You’ll Actually Want to Write

Continuing our coverage of Project Bicep (now v0.3), this version introduces loops, conditional deployment, and modules, making it a viable replacement for ARM JSON in production.

Loops

param storageCount int = 2

resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = [for i in range(0, storageCount): {
  name: 'sa${i}unique'
  location: resourceGroup().location
  sku: { name: 'Standard_LRS' }
  kind: 'StorageV2'
}]

Conditional Deployment

param deployApp bool

resource appService 'Microsoft.Web/sites@2020-06-01' = if (deployApp) {
  name: 'myapp'
  // ...
}

Key Takeaways

  • Bicep is transpiled to ARM JSON `bicep build main.bicep`.
  • IntelliSense works for all Azure resources immediately.
  • Much easier to read and review in Pull Requests than JSON.

Discover more from C4: Container, Code, Cloud & Context

Subscribe to get the latest posts sent to your email.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.