0
0
Azurecloud~5 mins

ARM template resources section in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
When you want to create or manage cloud resources in Azure, you need a way to describe what you want. The resources section in an ARM template lists all the cloud resources you want to create or update in your Azure environment.
When you want to deploy a virtual machine with specific settings automatically.
When you need to create a storage account along with your app without clicking in the portal.
When you want to update or add resources in a repeatable way across different environments.
When you want to share your infrastructure setup with your team as code.
When you want to automate resource deployment as part of a bigger process.
Config File - azuredeploy.json
azuredeploy.json
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2022-09-01",
      "name": "examplestorageacct",
      "location": "eastus",
      "sku": {
        "name": "Standard_LRS"
      },
      "kind": "StorageV2",
      "properties": {}
    }
  ]
}

The resources section lists all Azure resources to create or update.

Each resource has a type (what it is), apiVersion (which version of Azure API to use), name (unique name), location (where it lives), and properties (settings).

This example creates a storage account named examplestorageacct in the East US region.

Commands
This command deploys the ARM template to the resource group named example-rg, creating the resources defined in the resources section.
Terminal
az deployment group create --resource-group example-rg --template-file azuredeploy.json
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.Resources/deployments/deploymentName", "name": "deploymentName", "properties": { "provisioningState": "Succeeded", "outputs": {} }, "resourceGroup": "example-rg", "templateLink": null }
--resource-group - Specifies the target Azure resource group for deployment
--template-file - Specifies the ARM template file to deploy
This command checks that the storage account named examplestorageacct was created successfully in the example-rg resource group.
Terminal
az storage account show --name examplestorageacct --resource-group example-rg
Expected OutputExpected
{ "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/example-rg/providers/Microsoft.Storage/storageAccounts/examplestorageacct", "location": "eastus", "name": "examplestorageacct", "sku": { "name": "Standard_LRS" }, "kind": "StorageV2", "properties": { "provisioningState": "Succeeded" } }
--name - Specifies the name of the storage account to show
--resource-group - Specifies the resource group where the storage account exists
Key Concept

If you remember nothing else from this pattern, remember: the resources section in an ARM template is where you list every Azure resource you want to create or update, with all their settings.

Common Mistakes
Forgetting to specify the apiVersion for a resource.
Azure needs the apiVersion to know how to understand the resource settings; missing it causes deployment errors.
Always include a valid apiVersion for each resource type in the resources section.
Using a resource name that already exists in the resource group without intending to update.
This can cause conflicts or unexpected updates to existing resources.
Use unique names or carefully plan updates to existing resources.
Leaving the properties section empty or missing required properties for the resource type.
Some resources require specific properties to be set; missing them causes deployment failure.
Check Azure documentation for required properties and include them in the properties section.
Summary
The resources section in an ARM template defines all Azure resources to create or update.
Each resource needs a type, apiVersion, name, location, and properties.
Use the Azure CLI to deploy the template and verify the resources were created.