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

Azure ARM templates are powerful (JSON), but painful to write. JSON is not a programming language—it lacks variables, comments (standard JSON), and modules. Enter Project Bicep.

What is Bicep?

Bicep is a Domain Specific Language (DSL) that transpiles to ARM JSON. It’s a transparent abstraction—anything you can do in ARM, you can do in Bicep, but with 50% less code.

Comparison

ARM JSON

{
  "$schema": "...",
  "parameters": {
    "name": { "type": "string" }
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2019-06-01",
      "name": "[parameters('name')]",
      "location": "[resourceGroup().location]",
      "sku": { "name": "Standard_LRS" }
    }
  ]
}

Bicep

param name string
param location string = resourceGroup().location

resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {
  name: name
  location: location
  sku: {
    name: 'Standard_LRS'
  }
}

Why Bicep Wins

  • Modules: Truly reusable infrastructure components. module web 'webapp.bicep' = { ... }
  • IntelliSense: The VS Code extension is fantastic. It knows the Azure schema.
  • Safe Ordering: Bicep handles resource dependencies (dependsOn) implicitly for you by analyzing references.
  • Decompilation: You can turn existing ARM JSON into Bicep: bicep decompile main.json.

If you work with Azure, stop writing JSON. Learn Bicep.


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.