0
0
Azurecloud~5 mins

Storage account creation in Azure - Commands & Configuration

Choose your learning style9 modes available
Introduction
Creating a storage account in Azure lets you save files, backups, and data safely in the cloud. It solves the problem of needing a reliable place to keep your data accessible from anywhere.
When you want to store images and videos for your website.
When you need to back up important documents automatically.
When your app needs to save user data like profiles or settings.
When you want to share files securely with your team.
When you need a place to keep logs and analytics data.
Config File - storage-account-template.json
storage-account-template.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": "examplestorageacct01",
      "location": "eastus",
      "sku": {
        "name": "Standard_LRS"
      },
      "kind": "StorageV2",
      "properties": {
        "accessTier": "Hot"
      }
    }
  ]
}

This JSON file is an Azure Resource Manager (ARM) template that defines a storage account resource.

  • type: Specifies the resource type as a storage account.
  • apiVersion: The version of the Azure API to use.
  • name: The unique name of the storage account.
  • location: The Azure region where the storage account will be created.
  • sku: Defines the performance and replication type; here, Standard locally-redundant storage.
  • kind: Specifies the storage account type; StorageV2 supports blobs, files, queues, and tables.
  • properties.accessTier: Sets the access tier to 'Hot' for frequently accessed data.
Commands
This command creates a resource group named 'exampleResourceGroup' in the East US region. Resource groups hold related Azure resources together.
Terminal
az group create --name exampleResourceGroup --location eastus
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/exampleResourceGroup", "location": "eastus", "managedBy": null, "name": "exampleResourceGroup", "properties": { "provisioningState": "Succeeded" }, "tags": {}, "type": "Microsoft.Resources/resourceGroups" }
--name - Specifies the name of the resource group
--location - Specifies the Azure region for the resource group
This command deploys the storage account defined in the ARM template file to the resource group.
Terminal
az deployment group create --resource-group exampleResourceGroup --template-file storage-account-template.json
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/exampleResourceGroup/providers/Microsoft.Resources/deployments/deployment1", "name": "deployment1", "properties": { "provisioningState": "Succeeded", "outputs": {} } }
--resource-group - Specifies the target resource group for deployment
--template-file - Specifies the ARM template file to deploy
This command retrieves details about the storage account to confirm it was created successfully.
Terminal
az storage account show --name examplestorageacct01 --resource-group exampleResourceGroup
Expected OutputExpected
{ "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/exampleResourceGroup/providers/Microsoft.Storage/storageAccounts/examplestorageacct01", "location": "eastus", "name": "examplestorageacct01", "primaryEndpoints": { "blob": "https://examplestorageacct01.blob.core.windows.net/", "file": "https://examplestorageacct01.file.core.windows.net/", "queue": "https://examplestorageacct01.queue.core.windows.net/", "table": "https://examplestorageacct01.table.core.windows.net/" }, "sku": { "name": "Standard_LRS" }, "tags": {}, "type": "Microsoft.Storage/storageAccounts" }
--name - Specifies the storage account name to show
--resource-group - Specifies the resource group containing the storage account
Key Concept

If you remember nothing else from this pattern, remember: a storage account is a container in Azure where you keep your files and data safely and you create it by deploying a resource group and then the storage account resource.

Common Mistakes
Trying to create a storage account without first creating a resource group.
Azure requires resources to be inside a resource group; without it, the creation fails.
Always create or specify an existing resource group before deploying a storage account.
Using a storage account name that is not globally unique.
Storage account names must be unique across all Azure users; duplicates cause errors.
Choose a unique name using a combination of words and numbers to avoid conflicts.
Deploying the ARM template with syntax errors or missing required fields.
Invalid templates cause deployment failures and no storage account is created.
Validate the ARM template JSON syntax and required properties before deployment.
Summary
Create a resource group to hold your Azure resources.
Deploy a storage account using an ARM template to define its settings.
Verify the storage account creation by retrieving its details.