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.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Billboard image

Try REST API Generation for MS SQL Server.

DevOps for Private APIs. With DreamFactory API Generation, you get:

  • Auto-generated live APIs mapped from database schema
  • Interactive Swagger API documentation
  • Scripting engine to customize your API
  • Built-in role-based access control

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay