Infrastructure as Code (IaC)

Azure portal · dashboard health $ az vm create --name web01 failed… replacing ✓ auto-healed Fixes itself
Write the recipe once and build identical environments, as many times as you like.

😟 THE PROBLEM

Test and production were built by hand and behave differently.

😊 THE SOLUTION

Define infrastructure in code with Bicep, ARM templates or Terraform.

  • Environments don’t match✓ Same code, same result
  • New regions take weeks✓ Deploy from templates in hours
  • No record of changes✓ Version control and reviews
🛠️ Solved with: Infrastructure as code
Try it yourself in the Azure simulator No Azure account needed. Cloud Shell: deploy a web app ⌨️ Try it ❯
Module 3: Management & Governance ⏱ 6 min read Updated 11 Nov 2026

Quick answer

Infrastructure as code (IaC) means managing infrastructure, such as networks, VMs and databases, by writing code files instead of clicking. The files can be version-controlled, reviewed and deployed repeatedly, so every environment is consistent. On Azure, common IaC tools are Bicep, ARM templates and Terraform, which are mostly declarative: you describe the end state, and the tool works out how to reach it.

Exam objective: 3.3.4 Describe infrastructure as code (IaC). (Skills measured as of July 20, 2026)

Start with a question

Your test environment works perfectly, but production behaves differently. Why?

Because they were built by hand, at different times, by different people. Infrastructure as code builds them from the same recipe.

Explain it like I’m 10

The technical explanation

A small Bicep file describing a storage account:

resource st 'Microsoft.Storage/storageAccounts@2023-05-01' = {
  name: 'stlearn0412'
  location: 'westeurope'
  sku: { name: 'Standard_ZRS' }
  kind: 'StorageV2'
}

Deploy it with az deployment group create --resource-group rg-learn --template-file main.bicep. Run it again and nothing changes, because it is already in the desired state (idempotent).

Real-world business scenario

E-commerce

An e-commerce platform

The problem
Building a new region by hand took two weeks and still differed from the original.
What they used
All infrastructure defined in Bicep and deployed by pipeline.
Why that choice
Same code means the same environment every time.
The result
A new region now takes an afternoon and matches exactly.

When to use it and when not to

✓ Use it when…

  • All production environments.
  • Anything you deploy more than once.

✕ Think twice when…

  • Quick one-off experiments, where the portal or CLI is fine.
Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

Interview preparation

Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

Beginner What is infrastructure as code?

Model answer

Writing your cloud setup in code files, like a recipe, so you can create the same environment again and again exactly the same way.

Intermediate What is the difference between declarative and imperative IaC?

Model answer

Declarative describes the desired end state, like "a VM of this size in this network", and the tool works out the steps. Imperative lists each step to run in order, like a CLI script. Bicep, ARM templates and Terraform are declarative.

Experienced developer How does IaC fit into DevOps?

Model answer

Templates live in Git, changes go through pull requests and automated validation (linting, what-if previews, policy checks), and pipelines deploy them to dev, test and production. This gives auditable, repeatable environments and makes drift and disaster recovery easier to handle.

Test yourself with exercises

3 original practice questions in the AZ-900 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

Question 1

Question 1 of 3

What is infrastructure as code?

Question 2

Question 2 of 3 · Select 2

Which TWO are infrastructure-as-code tools for Azure?

Question 3

Question 3 of 3

What does a declarative approach mean?

Quick revision

Key points

  • IaC = infrastructure defined in code files.
  • Repeatable, consistent, version-controlled, reviewable.
  • Declarative (desired state) vs imperative (step by step).
  • Azure tools include Bicep, ARM templates and Terraform.

Important terminology

Infrastructure as code
Defining and deploying infrastructure through code files.
Declarative
Describe what you want; the tool decides how to create it.
Imperative
Write step-by-step commands, as in a script.
Bicep
A concise Azure language that compiles to ARM templates.

Common mistakes

  • Thinking IaC means only shell scripts. Declarative templates are the norm.

Exam tips

  • "Deploy identical environments repeatedly from files" = infrastructure as code.

Five quick revision questions

  1. 1.What is infrastructure as code?Show

    Managing infrastructure through code files.

  2. 2.Name two Azure IaC tools.Show

    Bicep and ARM templates (also Terraform).

  3. 3.What does declarative mean?Show

    Describing the desired end state rather than the steps.

  4. 4.Why store IaC in source control?Show

    For history, review and collaboration.

  5. 5.What does Bicep compile to?Show

    ARM templates.

Official references

Make it stick: play a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

Finished this lesson? Tick it off. Your progress is saved in this browser.

Next up: Azure Resource Manager and ARM Templates