Most of my Azure work so far has been clicking in the portal. That works until you need to do the same thing twice, explain exactly what you changed, or know what a change would do before you make it.
As part of my AZ-104 prep, I worked through this Microsoft Learn module and built everything in my own lab subscription. Here's what I learned, what broke, and how I'd use it day to day.
5 key takeaways
- An ARM template describes the end state you want, not the steps to get there.
- Deploying the same template again changes nothing, and
-WhatIfshows you that before anything happens. -
allowedValuesstops bad input at validation, before a single resource is created. - Changing a storage account's name in the template creates a new account; the old one stays.
- An empty storage account costs nothing. Data, operations and outbound traffic do.
Key points from the module
What an ARM template is. A JSON file that declares the Azure resources you want. You send it to Azure Resource Manager, which validates it and makes Azure match it. Two words matter:
- Declarative: you say what should exist, not how to create it.
- Idempotent: deploying the same template again gives the same result, with no copies and no delete-and-recreate.
What's inside. A template has a fixed set of sections:
| Section | What it holds | Required? |
|---|---|---|
$schema |
Which template language version the file uses | Yes |
contentVersion |
Your own version number for the template | Yes |
parameters |
Values you pass in at deploy time | No |
variables |
Values worked out inside the template | No |
functions |
Your own template functions | No |
resources |
The things to create or update | Yes |
outputs |
Values returned after deployment | No |
Where resource definitions come from. Every resource has a type made of a resource provider namespace and a resource type, such as Microsoft.Storage/storageAccounts. The template reference lists, per API version, every property, which ones are required and which values are allowed.
Ways to deploy. From your own machine (what I did), as a linked template, or from a CI/CD pipeline.
What I built, step by step
My setup: a Mac with PowerShell 7 and the Az module, VS Code for the JSON, and a throw-away resource group:
New-AzResourceGroup -Name "TestResourceGroup" -Location "swedencentral" `
-Tag @{ Environment = "test"; owner = "stlab" }
The module suggests Set-AzDefault so later commands can leave out the resource group. I skipped it. It saves a default in your local Az context, and my subscription also holds a VM in another resource group. I'd rather every command say exactly where it's going. A deployment only touches the resource group you name.
1. An empty template
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"functions": [],
"variables": {},
"resources": [],
"outputs": {}
}
$templateFile = "./azuredeploy.json"
New-AzResourceGroupDeployment -Name blanktemplate `
-ResourceGroupName TestResourceGroup `
-TemplateFile $templateFile
DeploymentName : blanktemplate
ResourceGroupName : TestResourceGroup
ProvisioningState : Succeeded
Mode : Incremental
Nothing was created, but a deployment record appeared in the resource group's history. Mode: Incremental is the default, and it matters later.
2. Add a storage account
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2025-01-01",
"name": "exerciselearning",
"location": "[resourceGroup().location]",
"sku": { "name": "Standard_LRS" },
"kind": "StorageV2"
}
This deployment took about 30 seconds instead of about one, because this time Azure built something real.
3. Make the name a parameter
Storage account names must be unique across Azure, so a hard-coded name doesn't scale. A parameter with length limits and no default forces you to pass one:
"storageName": {
"type": "string",
"minLength": 3,
"maxLength": 24,
"metadata": { "description": "The name of the Azure storage resource" }
}
Template parameters show up as cmdlet parameters:
New-AzResourceGroupDeployment -Name $deploymentName `
-ResourceGroupName TestResourceGroup `
-TemplateFile $templateFile `
-storageName "stlab01"
4. Limit the SKU with allowedValues, then break it on purpose
"storageSKU": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS",
"Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS"
]
}
-storageName "stlab02" -storageSKU Standard_GRS deployed fine. Then I passed Basic, which isn't a storage SKU:
Error: Code=InvalidTemplate; Message=Deployment template validation failed:
'The provided value for the template parameter 'storageSKU' is not valid.
The value 'Basic' is not part of the allowed value(s): 'Standard_LRS,Standard_GRS,...'.'
It failed at validation: no stlab03 account and no deployment record. The template protected itself.
But allowedValues only checks the text. I wondered whether Premium_LRS would even work with kind: StorageV2, so I previewed and validated it without deploying:
New-AzResourceGroupDeployment -ResourceGroupName TestResourceGroup `
-TemplateFile $templateFile -storageName "stlabprem2211" -storageSKU Premium_LRS -WhatIf
Test-AzResourceGroupDeployment -ResourceGroupName TestResourceGroup `
-TemplateFile $templateFile -storageName "stlabprem2211" -storageSKU Premium_LRS
+ Microsoft.Storage/storageAccounts/stlabprem2211 [2025-01-01]
kind: "StorageV2"
sku.name: "Premium_LRS"
Resource changes: 1 to create, 4 to ignore.
Test-AzResourceGroupDeployment printed nothing, which means validation passed (the Activity Log shows "Validate Deployment: Succeeded"). Premium_ZRS gave the same plan. Nothing was created.
So the combination is valid, but not what I expected. Microsoft's SKU reference lists Premium_LRS and Premium_ZRS with StorageV2 as premium page blob accounts: page blobs only, no file shares, tables or queues, and mainly meant for legacy unmanaged VM disks. Premium block blobs need kind: BlockBlobStorage, and premium file shares need kind: FileStorage. My template would have deployed happily, just into a very different kind of account.
5. Return something with an output
"outputs": {
"storageEndpoint": {
"type": "object",
"value": "[reference(parameters('storageName')).primaryEndpoints]"
}
}
After deployment, PowerShell prints the account's endpoints (blob, file, queue, table, dfs, web). Outputs are how one deployment hands a value to the next step.
The final template (click to expand)
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageName": {
"type": "string",
"minLength": 3,
"maxLength": 24,
"metadata": { "description": "The name of the Azure storage resource" }
},
"storageSKU": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS",
"Premium_LRS", "Premium_ZRS", "Standard_GZRS", "Standard_RAGZRS"
]
}
},
"functions": [],
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2025-01-01",
"name": "[parameters('storageName')]",
"tags": { "displayName": "[parameters('storageName')]" },
"location": "[resourceGroup().location]",
"sku": { "name": "[parameters('storageSKU')]" },
"kind": "StorageV2",
"properties": { "supportsHttpsTrafficOnly": true }
}
],
"outputs": {
"storageEndpoint": {
"type": "object",
"value": "[reference(parameters('storageName')).primaryEndpoints]"
}
}
}
How I checked it worked
Two read-only commands give proof I can paste anywhere:
Get-AzResourceGroupDeployment -ResourceGroupName TestResourceGroup |
Select-Object DeploymentName, ProvisioningState, Timestamp
Get-AzStorageAccount -ResourceGroupName TestResourceGroup |
Select-Object StorageAccountName, @{n='Sku';e={$_.Sku.Name}}, Kind
DeploymentName ProvisioningState Timestamp
addSkuParameter-11-18-2026 Succeeded 18.11.2026 01…
testdeployment3-11-18-2026 Succeeded 18.11.2026 00…
testdeployment2 Succeeded 17.11.2026 23…
testdeployment1 Succeeded 17.11.2026 23…
addstorage-11-16-2026 Succeeded 17.11.2026 00…
blanktemplate Succeeded 15.11.2026 22…
StorageAccountName Sku Kind
exerciselearning Standard_LRS StorageV2
exerciselearning1 Standard_LRS StorageV2
stlab01 Standard_LRS StorageV2
stlab02 Standard_GRS StorageV2
In the portal, the same history is under the resource group's Deployments. Open one to see its inputs, outputs, the exact template that ran, and a correlation ID to search for in the Activity Log. Each scope keeps up to 800 deployments, and Azure deletes the oldest automatically as you reach the limit. Deleting a history record doesn't touch the resources.
I also exported the resource group with Export-AzResourceGroup and compared it with my template. Azure's version had 20 resources instead of 4 (each account's blob, file, queue and table services), a hard-coded location, one parameter per account name, and defaults I never set, such as minimumTlsVersion: "TLS1_0". An export is great for reading what exists, not as a clean template to reuse.
The big idea: -WhatIf and idempotence
-WhatIf asks Resource Manager to compare your template with what exists and print a plan, without changing anything. I ran it twice against stlab02, which is currently GRS.
Run 1: ask for LRS.
New-AzResourceGroupDeployment -ResourceGroupName TestResourceGroup `
-TemplateFile $templateFile -storageName "stlab02" -storageSKU Standard_LRS -WhatIf
~ Microsoft.Storage/storageAccounts/stlab02 [2025-01-01]
~ sku.name: "Standard_GRS" => "Standard_LRS"
* Microsoft.Storage/storageAccounts/exerciselearning
* Microsoft.Storage/storageAccounts/exerciselearning1
* Microsoft.Storage/storageAccounts/stlab01
Resource changes: 1 to modify, 3 to ignore.
Run 2: ask for GRS, which is what already exists.
= Microsoft.Storage/storageAccounts/stlab02 [2025-01-01]
Resource changes: 1 no change, 3 to ignore.
That's idempotence in two screens:
- Run 1: one property differs, so the plan changes that one property in place. No new account, no delete-and-recreate.
- Run 2: nothing differs, so nothing happens. You could deploy it a hundred times.
- "3 to ignore": the other accounts exist but aren't in this template, so they aren't deployed or modified.
That last line is the difference between the two deployment modes. Incremental (the default) leaves resources that aren't in the template alone. Complete deletes them, so those three would become deletions. Microsoft's docs say Complete mode will be gradually deprecated, and point to deployment stacks for managing deletions instead.
What surprised me
-
A new name is a new resource. I renamed
exerciselearningtoexerciselearning1in the template to see what happens. Azure created a second account and left the first one alone. There's no rename for a storage account. - The naming rule is stricter than the module says. One exercise unit says hyphens are allowed in storage account names. They aren't: 3–24 characters, lowercase letters and numbers only, unique across Azure.
-
Skipping
Set-AzDefaultmeans a prompt. Whenever I left out-ResourceGroupName, PowerShell asked for it. Putting it in the command is cleaner. -
Variables keep old values. One deployment was named
addstorage-11-16-2026but ran on the 17th, because$todaystill held the earlier date. -
allowedValuesisn't a full safety net. It acceptsPremium_LRS, and withkind: StorageV2that turns the account into a premium page blob account. Valid, but probably not what you meant. A list of allowed values should only hold values that make sense together with the rest of the template.
Does it cost money?
An empty storage account has no fixed charge. Storage is billed for data stored, operations and data transfer.
| Action | Cost |
|---|---|
Resource group, deployments, -WhatIf, deployment history, tags |
Free |
| A storage account left empty | Free |
| Uploading data | Per GB per month, plus write operations |
| Reading or listing data | A tiny charge per 10,000 operations |
| Downloading data out of Azure | Free up to a monthly allowance, then per GB |
| GRS instead of LRS | A higher per-GB rate, still only on stored data |
A premium page blob account (Premium_LRS + StorageV2) |
Billed hourly per page blob by its provisioned size, not the data in it; blobs under 128 GB are billed at the P10 (128 GB) rate; no transaction charges |
The premium row is the one to watch: one small page blob is billed as a full 128 GB disk tier. Microsoft's pricing page doesn't say what an empty premium page blob account costs, and it showed no prices for my region, so check the pricing calculator for your region before deploying one. I didn't.
I'm keeping the four empty Standard accounts to review the deployments in the portal. To check your own numbers, use Cost Management → Cost analysis filtered to the resource group; the data can lag by a day.
Daily use in real life
This is where it stops being an exam topic:
- Repeatable test environments. One template, a new resource group, the same setup every time. Delete the group when you're done.
-
Consistent names and tags. Parameters with
allowedValuesand fixed tags in the template beat hoping everyone clicks the same options. -
A change preview before a maintenance window. Attach the
-WhatIfoutput to the change request: it lists exactly what will be created, modified or deleted. -
Spotting drift. Run
-WhatIfwith the template you think matches production. Anything marked Modify was changed by hand since. - Rebuilding after a mistake. If a resource is deleted, the template brings it back the way it was.
- Documenting what's already there. Export a resource group to understand an environment someone else built.
- Automating it later. The same template can run from a pipeline instead of a laptop. That's beyond AZ-104, but it's where this leads.
Exam tips
- Required template sections:
$schema,contentVersion,resources. - "Idempotent" describes behaviour; it isn't a template section.
- The default deployment mode is Incremental; Complete deletes what isn't in the template.
-
allowedValuesand length limits fail at validation (InvalidTemplate), before anything is deployed. - Changing a resource's name creates a new resource; changing its location or type makes the deployment fail.
-
-WhatIfpredicts changes and changes nothing;Test-AzResourceGroupDeploymentvalidates without deploying. - Premium storage depends on
kind:StorageV2= premium page blobs,BlockBlobStorage= premium block blobs,FileStorage= premium file shares.
Next: Bicep
The same storage account in Bicep, which compiles to exactly this JSON but is much easier to read:
param storageName string
param storageSKU string = 'Standard_LRS'
resource sa 'Microsoft.Storage/storageAccounts@2025-01-01' = {
name: storageName
location: resourceGroup().location
kind: 'StorageV2'
sku: { name: storageSKU }
}
output storageEndpoint object = sa.properties.primaryEndpoints
That's the next module in my plan, and the next post.
Resources
- Microsoft Learn: Deploy Azure infrastructure by using JSON ARM templates
- Docs: Template structure and syntax
- Docs: Parameters in ARM templates
- Docs: ARM template deployment what-if operation
- Docs: Deployment modes
- Docs: Storage account overview (naming rules)
- Docs: Automatic deletions from deployment history
- Docs: Storage SKU types and supported account kinds
- Pricing: Azure page blobs pricing
- Docs: Microsoft.Storage/storageAccounts template reference
Written from my own lab notes and command transcripts, with help from an AI assistant for drafting and structure. The commands and outputs are from my lab; storage account names are changed for this post. I checked the facts against Microsoft Learn and Docs before publishing.
Top comments (0)