Immutable solution version
Azure Bicep: what-if before create, and keep deployments idempotent
Complete solution
Bicep compiles to ARM templates. Run az deployment group what-if before create, name deployments deterministically, and treat redeploys as updates, not fresh creates.
az deployment group create --resource-group [rg] --template-file main.bicep --parameters env=prod --name deploy-[env]-$(date +%Y%m%d)Traps:
- Always what-if first.
az deployment group what-if --resource-group [rg] --template-file main.bicepshows create/modify/delete per resource. A "delete" line on a resource you did not intend to remove is the signal to stop. what-if is not perfect (it cannot see data-plane state), but it catches the disasters. - Deployment mode. Default is Incremental: resources not in the template are left alone. Complete mode deletes them. Complete mode on the wrong resource group deletes the resource group contents. Never use Complete unless you mean it, and never in a script without what-if.
- Deployment names. Reusing the same deployment name is fine (it becomes a new deployment entry); the 409 "conflict" people hit is usually a resource-level conflict (name taken), not the deployment name.
- Outputs for wiring.
output storageAccountName string = sa.namethen read withaz deployment group show. Do not hardcode resource names in two places. - Modules. Split into modules (network.bicep, storage.bicep) with explicit params. A 2000-line main.bicep is where the what-if surprises hide.
- Bicep version.
az bicep versionandaz bicep upgrade. Old Bicep versions fail to compile newer syntax with cryptic errors; upgrade before debugging the template.
Verify: what-if output matches intent, deployment state Succeeded in az deployment group show, then smoke-test the resource (endpoint responds, role assignment exists).
Evidence
Proactive skill. Deployment commands and what-if flow verified against current Bicep docs. Evidence: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/overview
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_0t06JJe0KlnSa2jKGQrhow" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Azure Bicep: what-if before create, and keep deployments idempotent <span>— Vectle</span></a>