Deploy, Export and Convert Templates to Bicep
30-second answer
Deploy a template to a resource group with az deployment group create --template-file main.bicep (or New-AzResourceGroupDeployment, or Deploy a custom template in the portal). Preview first with what-if. The default mode is Incremental, which adds and updates resources; Complete also deletes resources in the group that the template doesn't define. To get a template from what already exists, use Export template on a resource group or resource (or az group export), or download one from Deployments history. Convert ARM JSON to Bicep with az bicep decompile.
Simulate it » No Azure account neededExam objective: 3.1.4 Deploy resources by using an Azure Resource Manager template or a Bicep file. 3.1.5 Export a deployment as an Azure Resource Manager template or convert an Azure Resource Manager template to a Bicep file. (Skills measured as of April 17, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open <strong>Resource groups</strong> and select <strong>rg-contoso-prod</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open Resource groups and select rg-contoso-prod.
- Under Settings, open Deployments. Every template deployment into this group is recorded here.
- Each row keeps the template, inputs and outputs. Open storage. From here you can download its template or Redeploy it.
- Back on the resource group, Automation › Export template generates a template from the current resources. The ARM Template tab is JSON; the Bicep tab shows the same thing converted.
- The Bicep version is shorter and easier to review. To convert a JSON file yourself, use az bicep decompile in Cloud Shell.
- Export, decompile, then preview with what-if: ~ means modify, + create, - delete. Nothing changes until you deploy.
- Deploy with Incremental (the default: add and update). Complete also deletes anything in the group that the template doesn't list, so run what-if first and think twice.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
what-if, Incremental and Complete
what-if previews the changes (+ create, ~ modify, - delete) without touching anything. Incremental mode, the default, adds and updates. Complete mode also deletes whatever in the resource group isn't in the template.
🤔 What happens if…
Read this tour as text
- A Bicep file becomes resources. A template has four parts: parameters (inputs such as
storageNameandskuName), variables (values worked out once), resources (what gets built) and outputs (values handed back). The CLI compiles Bicep to ARM JSON and Azure Resource Manager validates it, then builds it. - what-if, Incremental and Complete. what-if previews the changes (
+create,~modify,-delete) without touching anything. Incremental mode, the default, adds and updates. Complete mode also deletes whatever in the resource group isn't in the template. - Export and decompile. Export template (portal, or
az group export) writes what exists now as ARM JSON.az bicep decompileturns JSON into Bicep. Both are starting points: names and values are hard-coded and some properties are missing. - A VM, its host and its size. A VM runs on a physical host in a hardware cluster. Its size (Standard_D2s_v5: D family, 2 vCPUs, premium storage, v5) sets CPU, memory, disk count and price. A resize restarts the VM; a size that isn't on the current cluster needs the VM deallocated first.
- Disks and encryption at host. OS and data disks are managed disks in Azure Storage, encrypted at rest by default. The temp disk and the disk caches live on the host. Encryption at host encrypts those too, end to end; it needs the feature registered and the VM deallocated.
- Move to another resource group or subscription. A move keeps the region and the VM keeps running, but every resource ID changes. The VM must travel with its disks and network interface; across subscriptions the virtual network goes too.
- Move to another region. Azure Resource Mover copies resources to another region: add them, validate dependencies, prepare, initiate move, then commit (or discard) and delete the source.
- Availability sets vs zones. An availability set spreads VMs over fault domains (racks with their own power and network) and update domains in one datacenter: 99.95%. Availability zones spread VMs over separate datacenters: 99.99%. A VM uses one or the other, chosen at creation.
- Scale sets grow on a rule. A Virtual Machine Scale Set (Flexible orchestration recommended) runs identical VMs across zones. Autoscale rules add instances when average CPU is high and remove them when it's low, always between the minimum and maximum.
Contoso keeps its storage accounts in Bicep. Read the file, change its default SKU, preview the change with what-if, deploy it, see what Complete mode would delete, then export the resource group and turn the JSON back into Bicep.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
A Complete-mode deployment deleted a database nobody had put in the template.
😊 THE SOLUTION
Preview with what-if and know what each deployment mode does.
- Surprise deletions✓ what-if before Complete mode
- No template for old resources✓ Export template
- JSON is hard to maintain✓ az bicep decompile
Start with a question
How do you rebuild a room exactly as it was, without throwing out what someone else put there?
You’ve got the floor plan for an office. Put the furniture back where the plan says and leave everything else alone: that’s one way. Make the room match the plan exactly, so anything not on the plan goes in the skip: that’s another.
Template deployments work the same. Incremental mode adds and fixes what’s on the plan. Complete mode also throws out what isn’t. And when you only have the room and no plan, Export template draws one for you.
Explain it like I’m 10
The technical explanation
Deploy
| Tool | Command or path |
|---|---|
| Azure CLI | az deployment group create -g rg-contoso-prod --template-file main.bicep --parameters storageName=stcontosologs |
| PowerShell | New-AzResourceGroupDeployment -ResourceGroupName rg-contoso-prod -TemplateFile main.bicep -storageName stcontosologs |
| Portal | Search Deploy a custom template › Build your own template in the editor (ARM JSON) |
| Other scopes | az deployment sub create, az deployment mg create, az deployment tenant create (they need --location) |
The CLI compiles Bicep for you. PowerShell needs the Bicep CLI installed. Parameters can come from the command line (key=value), a JSON parameters file (--parameters @main.parameters.json) or a .bicepparam file. The deployment name defaults to the template file name, and each one is kept in the resource group’s Deployments history (up to 800 per group; older entries are removed automatically).
Preview with what-if
az deployment group what-if -g rg-contoso-prod --template-file main.bicep --parameters storageName=stcontosologs
# ~ Microsoft.Storage/storageAccounts/stcontosologs
# ~ sku.name: "Standard_LRS" => "Standard_ZRS"
# Resource changes: 1 to modify.
The symbols are + create, ~ modify, - delete, = no change, * ignore. PowerShell uses -WhatIf on the same cmdlet. az deployment group create --confirm-with-what-if shows the preview and asks before deploying.
Incremental vs Complete
| Incremental (default) | Complete | |
|---|---|---|
| Resources in the template | Created or updated | Created or updated |
| Resources in the group but not in the template | Left alone | Deleted |
| How to choose | Nothing to add | --mode Complete / -Mode Complete |
| Use it for | Almost everything | A group that only this template owns |
Two details catch people out. In both modes a resource that is in the template gets the template’s properties, so a setting someone changed in the portal is reverted. And the portal’s custom deployment always runs Incremental. A CanNotDelete lock on a resource stops Complete mode from removing it.
Export what already exists
- Resource group or resource › Automation › Export template: generates a template from the current state, with ARM Template and Bicep tabs and an Include parameters option. Download it or select Deploy.
- Deployments history: open a past deployment and view or download the exact template and inputs it used.
- CLI / PowerShell:
az group export -n rg-contoso-prod > exported.json,az deployment group export -g rg-contoso-prod -n storage(one deployment’s template),Export-AzResourceGroup,Save-AzResourceGroupDeploymentTemplate.
Exported templates hard-code names and values, can’t include every resource type or property, and are limited to a few hundred resources per export. Treat them as a draft.
Convert to Bicep
az bicep decompile --file exported.json # creates exported.bicep (best effort, read the warnings)
az bicep build --file main.bicep # creates main.json (what Resource Manager deploys)
Architect level Deployment stacks and the end of Complete mode
Microsoft recommends deployment stacks over Complete mode for managing a set of resources as a unit. A stack (az stack group create) remembers which resources it created. When you remove one from the template, the stack can delete or detach it (--action-on-unmanage), and deny settings can stop people changing managed resources outside the stack. That gives you Complete mode’s clean-up without deleting things the template never owned. The exam still asks about Incremental and Complete, so learn those first.
Real-world business scenario
Fabrikam Health (fictional)
- The problem
- Years of portal clicks left a production resource group nobody could rebuild, and a test of Complete mode in staging deleted a shared Key Vault.
- What they used
- The team exported the production group, decompiled it with az bicep decompile, turned names into parameters and checked every deployment with what-if. They kept Incremental mode and put CanNotDelete locks on shared resources.
- Why that choice
- Export gave them a starting template for resources that were never scripted, and what-if showed every change before it happened.
- The result
- Production can be rebuilt from a reviewed Bicep file, and no deployment has deleted anything by surprise since.
When to use it and when not to
✓ Use it when…
- Incremental mode for routine deployments into shared resource groups.
- what-if before every production deployment, and always before Complete mode.
- Export template to capture resources that were built by hand.
✕ Think twice when…
- Complete mode in a resource group that other people or templates also use.
- Redeploying an exported template without cleaning it up first.
↔ Alternatives to consider
- Deployment stacks to manage and clean up a set of resources safely.
- Template specs to store versioned templates in Azure for others to deploy.
- GitHub Actions or Azure Pipelines to run what-if and deploy on every merge.
Test yourself with exercises
5 original practice questions in the AZ-104 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.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner Which command deploys a Bicep file to a resource group?
Model answer
az deployment group create --resource-group rg-name --template-file main.bicep, with --parameters for the inputs. In PowerShell it's New-AzResourceGroupDeployment with -TemplateFile. There are matching sub, mg and tenant commands for other scopes.
Intermediate What's the difference between Incremental and Complete mode?
Model answer
Incremental is the default. It creates or updates whatever is in the template and doesn't touch anything else in the resource group. Complete makes the group match the template exactly, so anything not in the template gets deleted. I'd only use Complete with what-if first and probably a delete lock on anything precious.
Experienced developer Why shouldn't you redeploy an exported template as it is?
Model answer
Export captures what exists now with names, IDs and values hard-coded. Some resource types and properties can't be exported, and it's capped at a number of resources. So I treat it as a starting point: decompile to Bicep, turn the hard-coded values into parameters, remove read-only properties, then test it with what-if.
Scenario A teammate wants to run a Complete-mode deployment on the production resource group to tidy it up. What do you do?
Model answer
I'd run what-if with --mode Complete first and read every line starting with a minus sign, because those get deleted. If anything there is in use, either it goes into the template or we stay in Incremental mode and remove leftovers deliberately.
Quick revision
Key points
- CLI az deployment group create, PowerShell New-AzResourceGroupDeployment, portal Deploy a custom template.
- Default mode is Incremental. Complete deletes resources not in the template.
- what-if previews - + create, ~ modify, - delete, = no change.
- Export template from a resource group or resource, or az group export. Deployment history keeps each template used.
- az bicep decompile converts JSON to Bicep; az bicep build compiles Bicep to JSON.
Important terminology
- Deployment
- One run of a template against a scope. It's recorded in the scope's deployment history with its template, parameters and outputs.
- Incremental mode
- The default deployment mode. Resources in the template are created or updated; others in the resource group are left alone.
- Complete mode
- A deployment mode that also deletes resources in the resource group that aren't in the template.
- what-if
- A preview of the changes a deployment would make (create, modify, delete, no change) without making them.
- Export template
- A portal and CLI feature that generates an ARM template (and a Bicep view) from existing resources.
- az bicep decompile
- The command that converts an ARM JSON template into a Bicep file, on a best-effort basis.
- Parameters file
- A JSON or .bicepparam file that supplies parameter values so they don't have to be typed on the command line.
Common mistakes
- Running Complete mode without what-if and deleting resources someone else added.
- Assuming an exported template captures every property and can be redeployed unchanged.
Exam tips
- "Delete resources not in the template" = Complete mode.
- "Preview changes without deploying" = what-if.
- "Convert an ARM template to Bicep" = az bicep decompile.
Five quick revision questions
-
1.What is the default deployment mode?Show
Incremental.
-
2.Which command previews a deployment's changes?Show
az deployment group what-if.
-
3.Which command exports a resource group as an ARM template?Show
az group export.
-
4.Which PowerShell cmdlet deploys a template to a resource group?Show
New-AzResourceGroupDeployment.
-
5.Where in the portal do you see the templates used for past deployments?Show
The resource group's Deployments blade.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Create Virtual Machines and Manage VM Sizes
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.