Deploying Azure Storage with ARM Templates.

Published: (February 8, 2026 at 10:05 AM EST)
2 min read
Source: Dev.to

Source: Dev.to

Introduction

Azure Resource Manager (ARM) provides a way to organize resources in Azure. With ARM you can define and deploy Azure resources as a single logical unit called a resource group, which can contain virtual machines, storage accounts, network interfaces, and more.

ARM templates are JSON files that define Infrastructure as Code (IaC). This guide shows how to deploy an Azure Storage Account using:

  • an ARM template
  • a PowerShell deployment script
  • an Azure DevOps pipeline

Prerequisites

  • Azure subscription
  • Azure DevOps project with a Service Connection to the subscription

Repository layout

├── deploy.ps1              # PowerShell script (creates RG + deploys template)
├── azure-pipelines.yml     # CI/CD pipeline definition
└── storageaccount.json     # ARM template definition

PowerShell deployment script (deploy.ps1)

param(
    [string]$ResourceGroupName,
    [string]$StorageAccountName,
    [string]$Location,
    [string]$Sku = "Standard_LRS"
)

$scriptDir = $PSScriptRoot    
$template = Join-Path $scriptDir "storageaccount.json"

Write-Host "Checking if resource group '$ResourceGroupName' already exists..."
Start-Sleep -Seconds 2
$exists = (az group exists --name $ResourceGroupName) -eq 'true'

if (-not $exists) {
    Write-Host "Resource group '$ResourceGroupName' does not exist. Creating..."
    az group create --name $ResourceGroupName --location $Location | Out-Null
    if ($LASTEXITCODE -ne 0) { throw "Failed to create resource group." }
} else {
    Write-Host "Resource group '$ResourceGroupName' already exists."
}

Write-Host "Deploying Azure ARM template.."

az deployment group create `
    --resource-group $ResourceGroupName `
    --template-file $template `
    --parameters "storageAccountName=$StorageAccountName" "sku=$Sku" "location=$Location"

if ($LASTEXITCODE -ne 0) {
    Write-Error "ARM deployment failed."
    return $false
}

Write-Host "Deployment successful by Alvaro! 🚀"

Azure Pipelines definition (azure-pipelines.yml)

trigger:
  branches:
    include:
      - main

pool:
  vmImage: 'ubuntu-latest'

variables:
  resourceGroupName: 'Asgard'
  storageAccountName: 'storageaccountasgard'
  location: 'West Europe'
  sku: 'Standard_LRS'

steps:
- task: AzureCLI@2
  displayName: 'Deploy Storage Account ARM Template'
  inputs:
    azureSubscription: 'Marty-MacFly'   # Service Connection name in Azure DevOps
    ScriptType: pscore
    ScriptPath: '$(System.DefaultWorkingDirectory)/deploy.ps1'
    ScriptArguments: >-
      -ResourceGroupName "$(resourceGroupName)"
      -StorageAccountName "$(storageAccountName)"
      -Location "$(location)"
      -Sku "$(sku)"

Running the pipeline

  1. Commit the files to the main branch of your Azure DevOps repository.
  2. The pipeline triggers automatically (or run it manually).
  3. The PowerShell script creates the resource group if it does not exist and deploys the storageaccount.json ARM template.

Verification

After the pipeline completes, navigate to the Azure portal and verify that the new Storage Account (storageaccountasgard) has been created in the West Europe region.

0 views
Back to Blog

Related posts

Read more »

Happy women in STEM day!! <3

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as we...