Create an Azure Storage account with the REST API
This sample shows how to create a new Azure Storage Account using the Azure REST API.
Complete reference documentation and additional samples are available in the Storage Resource Provider REST API Reference.
Build the request
Use the following HTTP PUT request to create a new Azure Storage account.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}?api-version=2018-02-01
Request headers
The following headers are required:
Request header | Description |
---|---|
Content-Type: | Required. Set to application/json . |
Authorization: | Required. Set to a valid Bearer access token. |
URI parameters
Name | Description |
---|---|
subscriptionId | The subscription ID that identifies an Azure subscription. If you have multiple subscriptions, see Working with multiple subscriptions. |
resourceGroupName | The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API, CLI, or the portal. |
accountName | The name of the storage account. Following naming accounts best practices is recommended. |
api-version | The API version to use for the request. This document covers api-version 2018-02-01 , included in the above URL. |
Request body
The table below describes the required JSON properties for the request body. Use optional parameters to further customize the storage account.
Name | Type | Description |
---|---|---|
location | string | Resource location. Get a current list of locations using the List Locations operation. |
kind | Kind | Specifies which type of storage account to create. The general-purpose StorageV2 choice is recommended and used in this sample. |
sku | Sku | Defines the capabilities of the Storage account, such as redundancy strategy and encryption. This sample uses Geo-Redundant storage. |
Example request body
{
"sku": {
"name": "Standard_GRS"
},
"kind": "StorageV2",
"location": "eastus2",
}
Handle the response
Successful requests to create a new account return a 202 status code with an empty response body. The storage account is created asynchronously. If the account already exists or is being provisioned, the request response has a 200 return code with the configuration of the existing storage account in the response body.
A full list of response codes, including error codes, are available in the Error code reference documentation.
Example 200 response code
{
"id": "/subscriptions/{subscriptionId}/resourceGroups/res9101/providers/Microsoft.Storage/storageAccounts/{accountName}",
"kind": "Storage",
"location": "eastus2",
"name": "{accountName}",
"properties": {
"creationTime": "2017-05-24T13:25:33.4863236Z",
"primaryEndpoints": {
"blob": "https://{accountName}.blob.core.windows.net/",
"file": "https://{accountName}.file.core.windows.net/",
"queue": "https://{accountName}.queue.core.windows.net/",
"table": "https://{accountName}.table.core.windows.net/"
},
"primaryLocation": "eastus2",
"provisioningState": "Succeeded",
"secondaryLocation": "centralus",
"statusOfPrimary": "available",
"statusOfSecondary": "available",
"supportsHttpsTrafficOnly": false
},
"sku": {
"name": "Standard_GRS",
"tier": "Standard"
},
"type": "Microsoft.Storage/storageAccounts"
}