Bicep Fundamentals

💤0
Lv 10 XP
← 📜 Infrastructure as Code · Bicep

Bicep Fundamentals

Beginner ⭐ 50 XP ⏱ 16 min #bicep#azure#iac

Author readable Azure infrastructure with Bicep, a clean DSL that compiles to ARM.

📖Theory

Bicep is a domain-specific language for deploying Azure resources. It’s a clean, typed layer over ARM templates — far more readable than ARM JSON, with no state file to manage (Azure tracks deployment state for you).

Core elements: param (inputs), var (computed values), resource (what to deploy), output (returned values), and modules for reuse. Bicep transpiles to ARM JSON, so anything ARM can do, Bicep can — with much less ceremony. Deployments are idempotent.

🌍Real-World Example
param location string = resourceGroup().location
param storageName string

resource sa 'Microsoft.Storage/storageAccounts@2023-01-01' = {
  name: storageName
  location: location
  sku: { name: 'Standard_LRS' }
  kind: 'StorageV2'
}

output storageId string = sa.id
az deployment group what-if -g rg-demo -f main.bicep -p storageName=stdemo01
az deployment group create   -g rg-demo -f main.bicep -p storageName=stdemo01
✍️Hands-On Exercise
  1. Identify the Bicep equivalents of inputs, variables, resources, and outputs.
  2. Write a Bicep resource for a storage account with a parameterized name.
  3. Explain why Bicep needs no separate state file.
  4. Use what-if (in words) to preview a deployment.
🧾Cheat Sheet
ElementKeyword
Inputparam
Computed valuevar
Resourceresource … '<type>@<api>'
Outputoutput
Reusemodule
Previewaz deployment group what-if
Deployaz deployment group create
💬Common Interview Questions
What is Bicep and how does it relate to ARM?

A concise DSL for Azure IaC that transpiles to ARM JSON. It offers the same capabilities with far better readability, modules, and tooling, and no separate state file.

Does Bicep have a state file like Terraform?

No. Azure Resource Manager tracks deployed resources, so there’s no state file to store or lock — you deploy templates and ARM reconciles to the desired state.

📚Official Documentation

📝 My notes on this topic

Auto-saves as you type