You will deploy Azure resources from a parameterized ARM template and preview changes with what-if before applying. By the end you will run repeatable, idempotent deployments instead of one-off portal clicks.

Learning Objectives

  • Author an ARM template with parameters.
  • Preview changes with the what-if operation.
  • Deploy idempotently and confirm no drift on re-run.
  • Time: ~3 hours · Difficulty: Intermediate · Prereqs: the Azure CLI and a resource group.

Architecture Overview

Environment Setup

You will need: the Azure CLI and a target resource group.

Before you begin: always run what-if before deploying to production scopes.

Step-by-Step Execution

01
Write a parameterized template
# template.json (excerpt)
"parameters": { "saName": { "type": "string" } },
"resources": [{
  "type": "Microsoft.Storage/storageAccounts",
  "apiVersion": "2023-01-01",
  "name": "[parameters('saName')]",
  "location": "[resourceGroup().location]",
  "sku": { "name": "Standard_LRS" },
  "kind": "StorageV2"
}]
02
Preview with what-if

what-if shows exactly what will change before anything is created or modified.

az deployment group what-if -g tyf-rg --template-file template.json --parameters saName=tyfstore01
03
Deploy
$ az deployment group create -g tyf-rg --template-file template.json --parameters saName=tyfstore01
"provisioningState": "Succeeded"

Progress So Far

Testing & Validation

az deployment group what-if -g tyf-rg --template-file template.json --parameters saName=tyfstore01

Re-running what-if after a successful deploy should report no changes, proving the template is idempotent.

Troubleshooting
  • Name already taken: storage account names are globally unique; choose another.
  • Validation failed: run az deployment group validate to see the schema error.
  • Unexpected what-if changes: a property drifted in the portal; let the template be the source of truth.

Extension Ideas

Key Results

  • Deployed resources declaratively from a parameterized template.
  • Previewed every change with what-if before applying.
  • Confirmed idempotency: a re-run reported no changes.
  • Replaced manual portal steps with repeatable deployments.