An Azure storage account contains all of your Azure Storage data objects: blobs, files, queues, tables, and disks. The storage account provides a unique namespace for your Azure Storage data that is accessible from anywhere in the world over HTTP or HTTPS. Data in your Azure storage account is durable and highly available, secure, and massively scalable.
This article has been updated to use the Azure Az PowerShell module. The Az PowerShell module is
the recommended PowerShell module for interacting with Azure. To get started with the Az
PowerShell module, see Install Azure PowerShell. To learn how
to migrate to the Az PowerShell module, see
Migrate Azure PowerShell from AzureRM to Az.
Prerequisites
If you don't have an Azure subscription, create a free account before you begin.
To create an Azure storage account with PowerShell, make sure you have installed Azure PowerShell module Az version 0.7 or later. For more information, see Introducing the Azure PowerShell Az module.
To find your current version, run the following command:
You can sign in to Azure and run Azure CLI commands in one of two ways:
You can run CLI commands from within the Azure portal, in Azure Cloud Shell.
You can install the CLI and run CLI commands locally.
Use Azure Cloud Shell
Azure Cloud Shell is a free Bash shell that you can run directly within the Azure portal. The Azure CLI is pre-installed and configured to use with your account. Click the Cloud Shell button on the menu in the upper-right section of the Azure portal:
The button launches an interactive shell that you can use to run the steps outlined in this how-to article:
Install the CLI locally
You can also install and use the Azure CLI locally. The examples in this article require Azure CLI version 2.0.4 or later. Run az --version to find your installed version. If you need to install or upgrade, see Install the Azure CLI.
Sign in to your Azure subscription with the Connect-AzAccount command and follow the on-screen directions to authenticate.
Connect-AzAccount
To launch Azure Cloud Shell, sign in to the Azure portal.
To log into your local installation of the CLI, run the az login command:
az login
N/A
Create a storage account
Every storage account must belong to an Azure resource group. A resource group is a logical container for grouping your Azure services. When you create a storage account, you have the option to either create a new resource group, or use an existing resource group. This article shows how to create a new resource group.
A general-purpose v2 storage account provides access to all of the Azure Storage services: blobs, files, queues, tables, and disks. The steps outlined here create a general-purpose v2 storage account, but the steps to create any type of storage account are similar. For more information about types of storage accounts and other storage account settings, see Azure storage account overview.
To create a general-purpose v2 storage account in the Azure portal, follow these steps:
On the Azure portal menu, select All services. In the list of resources, type Storage Accounts. As you begin typing, the list filters based on your input. Select Storage Accounts.
On the Storage Accounts window that appears, choose Add.
On the Basics tab, select the subscription in which to create the storage account.
Under the Resource group field, select your desired resource group, or create a new resource group. For more information on Azure resource groups, see Azure Resource Manager overview.
Next, enter a name for your storage account. The name you choose must be unique across Azure. The name also must be between 3 and 24 characters in length, and may include only numbers and lowercase letters.
Select a location for your storage account, or use the default location.
Select a performance tier. The default tier is Standard.
Set the Account kind field to Storage V2 (general-purpose v2).
Specify how the storage account will be replicated. The default replication option is Read-access geo-redundant storage (RA-GRS). For more information about available replication options, see Azure Storage redundancy.
Additional options are available on the Networking, Data protection, Advanced, and Tags tabs. To use Azure Data Lake Storage, choose the Advanced tab, and then set Hierarchical namespace to Enabled. For more information, see Azure Data Lake Storage Gen2 Introduction
Select Review + Create to review your storage account settings and create the account.
Select Create.
The following image shows the settings on the Basics tab for a new storage account:
First, create a new resource group with PowerShell using the New-AzResourceGroup command:
# put resource group in a variable so you can use the same group name going forward,
# without hard-coding it repeatedly
$resourceGroup = "storage-resource-group"
$location = "westus"
New-AzResourceGroup -Name $resourceGroup -Location $location
If you're not sure which region to specify for the -Location parameter, you can retrieve a list of supported regions for your subscription with the Get-AzLocation command:
Get-AzLocation | select Location
Next, create a general-purpose v2 storage account with read-access geo-redundant storage (RA-GRS) by using the New-AzStorageAccount command. Remember that the name of your storage account must be unique across Azure, so replace the placeholder value in brackets with your own unique value:
If you plan to use Azure Data Lake Storage, include -EnableHierarchicalNamespace $True in this list of parameters.
To create a general-purpose v2 storage account with a different replication option, substitute the desired value in the table below for the SkuName parameter.
Replication option
SkuName parameter
Locally redundant storage (LRS)
Standard_LRS
Zone-redundant storage (ZRS)
Standard_ZRS
Geo-redundant storage (GRS)
Standard_GRS
Read-access geo-redundant storage (GRS)
Standard_RAGRS
Geo-zone-redundant storage (GZRS)
Standard_GZRS
Read-access geo-zone-redundant storage (RA-GZRS)
Standard_RAGZRS
First, create a new resource group with Azure CLI using the az group create command.
az group create \
--name storage-resource-group \
--location westus
If you're not sure which region to specify for the --location parameter, you can retrieve a list of supported regions for your subscription with the az account list-locations command.
az account list-locations \
--query "[].{Region:name}" \
--out table
Next, create a general-purpose v2 storage account with read-access geo-redundant storage by using the az storage account create command. Remember that the name of your storage account must be unique across Azure, so replace the placeholder value in brackets with your own unique value:
If you plan to use Azure Data Lake Storage, include --enable-hierarchical-namespace true in this list of parameters.
To create a general-purpose v2 storage account with a different replication option, substitute the desired value in the table below for the sku parameter.
Replication option
sku parameter
Locally redundant storage (LRS)
Standard_LRS
Zone-redundant storage (ZRS)
Standard_ZRS
Geo-redundant storage (GRS)
Standard_GRS
Read-access geo-redundant storage (GRS)
Standard_RAGRS
Geo-zone-redundant storage (GZRS)
Standard_GZRS
Read-access geo-zone-redundant storage (RA-GZRS)
Standard_RAGZRS
You can use either Azure PowerShell or Azure CLI to deploy a Resource Manager template to create a storage account. The template used in this how-to article is from Azure Resource Manager quickstart templates. To run the scripts, select Try it to open the Azure Cloud Shell. To paste the script, right-click the shell, and then select Paste.
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
$location = Read-Host -Prompt "Enter the location (i.e. centralus)"
New-AzResourceGroup -Name $resourceGroupName -Location "$location"
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.json"
echo "Enter the Resource Group name:" &&
read resourceGroupName &&
echo "Enter the location (i.e. centralus):" &&
read location &&
az group create --name $resourceGroupName --location "$location" &&
az deployment group create --resource-group $resourceGroupName --template-uri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.json"
Note
This template serves only as an example. There are many storage account settings that aren't configured as part of this template. For example, if you want to use Azure Data Lake Storage, you would modify this template by setting the isHnsEnabledad property of the StorageAccountPropertiesCreateParameters object to true.
To learn how to modify this template or create new ones, see:
az storage account delete --name <storage-account> --resource-group <resource-group>
To delete the storage account, use either Azure PowerShell or Azure CLI.
$storageResourceGroupName = Read-Host -Prompt "Enter the resource group name"
$storageAccountName = Read-Host -Prompt "Enter the storage account name"
Remove-AzStorageAccount -Name $storageAccountName -ResourceGroupName $storageResourceGroupName
echo "Enter the resource group name:" &&
read resourceGroupName &&
echo "Enter the storage account name:" &&
read storageAccountName &&
az storage account delete --name storageAccountName --resource-group resourceGroupName
Alternately, you can delete the resource group, which deletes the storage account and any other resources in that resource group. For more information about deleting a resource group, see Delete resource group and resources.
Warning
It's not possible to restore a deleted storage account or retrieve any of the content that it contained before deletion. Be sure to back up anything you want to save before you delete the account. This also holds true for any resources in the account—once you delete a blob, table, queue, or file, it is permanently deleted.
If you try to delete a storage account associated with an Azure virtual machine, you may get an error about the storage account still being in use. For help troubleshooting this error, see Troubleshoot errors when you delete storage accounts.