DEV Community

Cover image for Deploying Multiple Instances of a Storage Account using an ARM templates
Oluwatobiloba Akinbobola
Oluwatobiloba Akinbobola

Posted on

1

Deploying Multiple Instances of a Storage Account using an ARM templates

INTRODUCTION

To investigate how to install multiple instances of a storage account in Azure using Azure Resource Manager (ARM) Templates and Azure CLI in this article. Azure CLI is a command-line tool for administering Azure resources. In contrast, ARM templates are JSON files that provide the setup and infrastructure for your Azure resources.

PROCEDURE

Step 1: Set Up the Resource Group
1.To create a resource group that organizes your resources. Run the following command in Azure CLI:

az group create -n storage-rg -l "eastus"
Enter fullscreen mode Exit fullscreen mode

2.To verify the resource group was created, list all resource groups:

az group list -o table
Enter fullscreen mode Exit fullscreen mode

create storage group

Step 2: Create an ARM Template
Create an ARM template (e.g., storage.json) to define the storage accounts. Below is an example template that deploys multiple storage accounts using the copy element:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "apiVersion": "2023-01-01",
      "name": "[concat('mystorage', copyIndex())]",
      "location": "[resourceGroup().location]",
      "sku": {
        "name": "Standard_LRS"
      },
      "kind": "StorageV2",
      "properties": {},
      "copy": {
        "name": "storageCopy",
        "count": 3
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

This template creates 3 storage accounts with similar names

Step 3: Deploy the ARM Template
Use the following command to deploy the template:

az deployment group create --resource-group storage-rg --template-file storage.json
Enter fullscreen mode Exit fullscreen mode

This command deploys the resources defined in storage.json to the storage-rg resource group.

Step 4: Verify the Deployment
Once the deployment is complete, you can check the storage accounts in the Azure portal or use Azure CLI to list them:

portal storage

az storage account list --resource-group miRG -o table
Enter fullscreen mode Exit fullscreen mode

Step 5: Export the Resource Group Configuration
If you want to export the current configuration of your resource group as an ARM template, use:

az group export --name storage-rg --output json > exported-storage.json
Enter fullscreen mode Exit fullscreen mode

This exports the resource group’s configuration to a file named exported-storage.json.

exported-storage.json

CONCLUSION

This article demonstrates creating a resource group using Azure CLI, creating an ARM template for multiple storage accounts, deploying the template, and exporting the configuration as an ARM template.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay