Home › Studies › AZ-104 › Compute › ARM Templates & Bicep

ARM Templates & Bicep

read a template · modes · loops · dependencies · what-if · export and convert

By the tools4free.dev team · Last reviewed November 13, 2026

Practice questions for this topic →

Reading a Bicep file

SnippetWhat it means
targetScope = 'subscription'Deployment scope. Allowed values: resourceGroup (the default, no need to set it), subscription, managementGroup, tenant. A module can use a different scope.
param storagePrefix stringA parameter with no default value: it must be supplied.
param storageSKU string = 'Standard_LRS'A parameter with a default value.
@secure() on a paramThe value is not saved to deployment history and is not logged. ARM equivalent: securestring / secureObject.
var name = '${prefix}${uniqueString(resourceGroup().id)}'A variable: computed inside the file. A param is supplied at deployment time.
resource stg 'Microsoft.Storage/storageAccounts@2025-06-01' = {…}Declares a resource. stg is its symbolic name.
resource dns '…' = if (deployZone) {…}Conditional deployment. ARM JSON uses "condition": true.
[for i in range(0, 5): {…}]Loop. Also [for item in array: {…}], [for (item, i) in array: {…}] and [for x in items(object): {…}]. Each instance needs a unique name. Max 800 iterations, never negative.
@batchSize(2) above a loopDeploys 2 instances at a time. Loops run in parallel by default; @batchSize(1) is fully sequential.
dependsOn: [ dns ]Explicit dependency. Rarely needed.
existing keywordDeclares a resource to read, not to deploy.
module m './file.bicep' = { name: '…', params: {…} }Calls a module. Read its outputs as m.outputs.x.
output storageEndpoint object = stg.properties.primaryEndpointsAn output.

ARM JSON template

Deployment modes

Incremental (default)Complete
Resources in the group that are not in the templateLeft unchangedDeleted
RG has A, B, C; template has A, B, DA, B, C, DA, B, D (C deleted)
Where it worksEverywhereRoot-level templates only (linked and nested templates must be incremental). Not subscription-level deployments. Not the portal. A locked resource group is not emptied. Only the RG named in the command is eligible for deletion.

Preview, export and convert

TaskHowNotes
Preview a deploymentWhat-ifWorks for RG, subscription, management group and tenant deployments. Change types: Create, Delete (complete mode only), Ignore, NoChange, NoEffect, Modify, Deploy. It cannot resolve reference, so it reports those properties as changing.
Export current state (portal)From the resource group or resourceAutogenerated snapshot of the current state. Includes manual changes made after deployment. Mostly hard-coded values; usually needs clean-up.
Export the original template (portal)Resource group › Deployments › pick a deployment › Template (Save from history)Exact copy of the template used, ARM JSON only, includes parameters, ready to redeploy. Excludes later manual changes.
ARM JSON to Bicepaz bicep decompile --file main.jsonCreates main.bicep next to the file. --force overwrites. Best-effort: output may need fixes.
Bicep to ARM JSONaz bicep build --file main.bicepProduces functionally equivalent JSON.

Limits

ItemValue
Parameters per template256
Variables per template256
Resources per template800
Outputs per template64
Loop or copy iterations800, never negative
Resources in an RG for portal export200
Minimum Azure CLI for Bicep deployment2.20.0

CLI and PowerShell

TaskAzure CLIPowerShell
Deploy to a resource groupaz deployment group create -g <rg> --template-file main.bicep --parameters storageAccountType=Standard_GRSNew-AzResourceGroupDeployment -ResourceGroupName <rg> -TemplateFile main.bicep
Deploy to a subscriptionaz deployment sub create --location <loc> --template-file main.bicepNew-AzSubscriptionDeployment
Deploy to a management group or tenantaz deployment mg create / az deployment tenant create (both need --location)
Complete modeaz deployment group create --mode Complete …New-AzResourceGroupDeployment -Mode Complete …
Preview (what-if)az deployment group what-if …, or --confirm-with-what-if / -cNew-AzResourceGroupDeployment -Whatif or -Confirm
Bicep parameter fileaz deployment group create -g <rg> --parameters storage.bicepparam
ARM to Bicepaz bicep decompile --file main.jsonbicep decompile main.json
Bicep to ARMaz bicep build --file main.bicepbicep build main.bicep
Export an RG templateaz group export --name <rg>Export-AzResourceGroup -ResourceGroupName <rg> -Path ./main.json

Only az deployment group takes --resource-group. The sub, mg and tenant versions take --location.

Exam Tips

Tick each tip once you can answer it without looking.

“Redeploy the template without deleting resources that are not in it” → Incremental mode (the default). Trap: Complete mode deletes unlisted resources.

“Make the resource group match the template exactly, removing extras” → Complete mode (--mode Complete). Trap: incremental leaves the extras in place.

“RG has A, B, C; template has A, B, D; incremental deployment” → A, B, C and D. Trap: assuming C is removed.

“Deploy in complete mode from the portal” → Not supported: use the CLI or PowerShell. Trap: looking for a portal option.

“Preview what a deployment will change” → What-if (az deployment group what-if). Trap: exporting a template shows the current state, not planned changes.

“Convert an existing ARM JSON template to Bicep” → az bicep decompile --file main.json. Trap: az bicep build goes the other way, Bicep to JSON.

“Need the exact template that created the resources, ready to redeploy” → Export from the deployment history. Trap: exporting the resource group gives an autogenerated snapshot that needs clean-up.

“Capture manual changes made after deployment into a template” → Export from the resource group or resource. Trap: the history template excludes later changes.

“Export a resource group with 250 resources” → Fails: the limit is 200 resources, so export a subset.

“Create 5 storage accounts in Bicep” → A [for i in range(0, 5): {…}] loop with a unique name per instance. Trap: giving every instance the same name.

“Deploy loop instances two at a time” → @batchSize(2) (ARM: copy mode serial, batchSize 2). Trap: the default is parallel, and batchSize 1 is fully sequential.

“ARM copyIndex() for the first instance” → 0 (zero-based). Trap: 1.

“Resource B reads a property of resource A by symbolic name” → Implicit dependency: no dependsOn needed. Trap: adding dependsOn is unnecessary and can slow deployment.

“Pass an admin password without it appearing in deployment history” → @secure() parameter (securestring in ARM). Trap: a plain string parameter.

“Deploy a Bicep file at subscription scope” → targetScope = 'subscription' and az deployment sub create --location. Trap: az deployment group create needs a resource group.

“Redeploy a vnet template and the subnets vanished” → Define subnets in the vnet subnets property; omitted properties reset to defaults on redeploy.

“User can write VMs but the template deployment is denied” → They also need Microsoft.Resources/deployments/*.

“Required elements of an ARM template” → $schema, contentVersion, resources. Trap: parameters and outputs are optional.

“Deploy a resource only when a bool parameter is true” → Bicep if (param) / ARM condition.

Sources

Checked against Microsoft Learn on November 13, 2026.

← Compute overviewVirtual Machines →