Bird
Raised Fist0
Azurecloud~5 mins

ARM template resources section in Azure - Commands & Configuration

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
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.

Practice

(1/5)
1. What is the main purpose of the resources section in an ARM template?
easy
A. To list all cloud parts to create or update
B. To write scripts for manual deployment
C. To store user credentials securely
D. To monitor cloud resource usage

Solution

  1. Step 1: Understand the role of the resources section

    The resources section defines what cloud parts (like servers, databases) to create or update automatically.
  2. Step 2: Compare options with this role

    Only To list all cloud parts to create or update correctly describes this purpose. Other options describe unrelated tasks.
  3. Final Answer:

    To list all cloud parts to create or update -> Option A
  4. Quick Check:

    Resources section = list cloud parts [OK]
Hint: Resources section always defines cloud parts to deploy [OK]
Common Mistakes:
  • Thinking resources section stores credentials
  • Confusing resources with monitoring tools
  • Assuming resources section is for scripts
2. Which of the following is a required property inside each resource in the resources section of an ARM template?
easy
A. version
B. dependsOn
C. location
D. tags

Solution

  1. Step 1: Identify required properties for each resource

    Every Azure resource requires type, apiVersion, and name. The location property is required for regional resources to specify where the resource is created.
  2. Step 2: Check options for required property

    location (location) is required. version is incorrect; the correct property is apiVersion. tags and dependsOn are optional.
  3. Final Answer:

    location -> Option C
  4. Quick Check:

    Location is required for resource placement [OK]
Hint: Location is required for regional resources [OK]
Common Mistakes:
  • Confusing apiVersion with version
  • Assuming tags are mandatory
  • Thinking dependsOn is always required
3. Given this resource snippet in an ARM template's resources section:
{
  "type": "Microsoft.Storage/storageAccounts",
  "apiVersion": "2022-09-01",
  "name": "mystorageaccount",
  "location": "eastus",
  "sku": { "name": "Standard_LRS" },
  "kind": "StorageV2"
}

What will happen when this template is deployed?
medium
A. Deployment fails due to missing 'dependsOn' property
B. A new storage account named 'mystorageaccount' is created in East US
C. The storage account is created but with default SKU
D. The template will error because 'kind' is invalid

Solution

  1. Step 1: Analyze resource properties

    The resource defines a storage account with a valid type, apiVersion, name, location, sku, and kind. All required fields are present and valid.
  2. Step 2: Understand deployment behavior

    Since all required properties are correct, deployment will create the storage account named 'mystorageaccount' in 'eastus' with the specified SKU and kind. dependsOn is optional here.
  3. Final Answer:

    A new storage account named 'mystorageaccount' is created in East US -> Option B
  4. Quick Check:

    Valid resource properties = successful creation [OK]
Hint: Check required fields; missing dependsOn is okay if no dependencies [OK]
Common Mistakes:
  • Thinking dependsOn is always mandatory
  • Assuming default SKU applies if specified
  • Believing 'kind' property is invalid
4. You have this resource in your ARM template's resources section:
{
  "type": "Microsoft.Web/sites",
  "apiVersion": "2021-02-01",
  "name": "mywebapp",
  "location": "westus"
}

Deployment fails with an error about missing properties. What is the likely cause?
medium
A. Missing 'properties' section with site configuration
B. Missing required 'kind' property for web app
C. Missing 'dependsOn' property for resource order
D. Missing 'sku' property defining pricing tier

Solution

  1. Step 1: Review required properties for Microsoft.Web/sites

    Besides type, apiVersion, name, and location, a web app resource requires a properties section to define site settings.
  2. Step 2: Identify missing required section

    The snippet lacks the properties section, causing deployment failure. sku and dependsOn are optional, and kind defaults to 'app' if omitted.
  3. Final Answer:

    Missing 'properties' section with site configuration -> Option A
  4. Quick Check:

    Web app needs properties section [OK]
Hint: Web apps require properties section; check for it [OK]
Common Mistakes:
  • Assuming dependsOn is mandatory
  • Confusing kind as required
  • Ignoring properties section necessity
5. You want to deploy two resources in an ARM template: a storage account and a web app that uses that storage. How do you ensure the web app deploys only after the storage account is ready?
hard
A. Use the same 'apiVersion' for both resources
B. Place the web app resource before the storage account in the resources array
C. Set the web app's 'location' to the storage account's location
D. Add the storage account's name in the web app's 'dependsOn' property

Solution

  1. Step 1: Understand resource deployment order control

    ARM templates use the dependsOn property to specify that one resource must finish deploying before another starts.
  2. Step 2: Apply dependsOn for correct order

    Adding the storage account's resource name in the web app's dependsOn ensures the web app waits for the storage account to be ready.
  3. Final Answer:

    Add the storage account's name in the web app's 'dependsOn' property -> Option D
  4. Quick Check:

    dependsOn controls deployment order [OK]
Hint: Use dependsOn to order resource deployment [OK]
Common Mistakes:
  • Thinking resource order in array controls deployment
  • Believing apiVersion affects deployment order
  • Assuming location controls deployment sequence