Lab: Bicep deploy, preview, and rollback

Outcome

Edit a small Bicep file, build and lint it, preview its changes, deploy it with a named resource-group deployment, diagnose an invalid change, and revert the desired state.

Do

  1. Create a disposable resource group and a main.bicep that deploys a tagged storage account with parameters for name, location, SKU, and a deployName output. Run az bicep build --file main.bicep and az bicep lint --file main.bicep.

  2. Run az deployment group what-if --resource-group <rg> --template-file main.bicep --parameters storageName=<unique-name>; inspect the predicted changes. Deploy only after the output matches the intended state:

    az deployment group create --name training-initial --resource-group <rg> \
      --template-file main.bicep --parameters storageName=<unique-name>
  3. Change only the tag value, build/lint/what-if again, and deploy it under a new name. Inspect deployment history, outputs, and the resource tag.

Verify

Keep build/lint output, both what-if results, deployment names/outputs, and portal/CLI resource state. You should now understand: Bicep is source; ARM evaluates the deployment; what-if predicts but does not apply changes; deployment history records each attempt.

Break and fix

  1. Introduce an invalid property or parameter type. Capture build/lint or ARM validation output, correct the source, and re-run the full preview.
  2. Make an unintended SKU/tag change. Stop at what-if, revert the source, and prove the preview is empty or intended. If already deployed, restore the earlier desired configuration with a new deployment; do not edit generated JSON as the canonical source.

Scenario practice

  1. Configure: Select parameter boundaries and deployment scope for a reusable resource-group template.
  2. Diagnose: A deployment fails after what-if. Inspect Bicep diagnostics, deployment operations, RBAC, provider registration, and actual resource constraints.
  3. Distinguish: Contrast build/lint, what-if, validation, deployment history, and rollback by desired-state redeployment.

Clean up

Delete the training resource group and local generated JSON artifact if it was created only for the lab.

Sources and re-audit

Re-audit when Bicep validation, what-if, or deployment commands change.

bicep · arm · azure-cli · All labs