DEV Community

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

Posted on

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.

Top comments (0)