You can create Azure Storage Account using Azure REST APIs in POSTMAN.

Pre-requisites:

  • You have installed POSTMAN
  • You have access to portal.azure.com

Steps:

  • Create Azure Service Principal
  • Create Resource Group
  • Create request in POSTMAN

1. Create Azure Service Principal using Azure CLI. Login to portal.azure.com and invoke cloud shell

2. Create an Azure service principal “sp_for_creating_storageAccount“.

az ad sp create-for-rbac --name "sp_for_creating_storageAccount" --role contributor

The appId and tenant keys appear in the output of az ad sp create-for-rbac and are used in service principal authentication. Record their values, but they can be retrieved at any point with az ad sp list.

3. Create Resource Group where Storage account will be created

az group create --location westus --name rg_for_storageAccount

 

4. Open POSTMAN and Create a collection

5. Create environment and add following variables

client_id – This is the value of appId from the service principal creation output above.

client_secret – This is the value of password from the service principal creation output above.

tenantid – This is the value of tenantId from the service principal creation output above.

resource – The default value is for managing Azure resources.(https://management.azure.com/)

subscriptionId – You can get this with this Azure CLI command az account show --query id

resourceGroupName – This is the value of name from the resource group creation output above.

accountName – Add the Storage account name which you want to create.

grant_type – client_credentials

access_token – You do not need to set this.

 

6. Now create a GET request to get Auth bearer access token. This request will receive bearer token. Using below script in Tests, you can set the token value to “access_token” environment variable.

var data = JSON.parse(responseBody);
postman.setEnvironmentVariable("access_token", data.access_token);

 

 

 

7. Now create PUT request to call REST API to create storage account.

 

 

8. Submit the request to create the storage account. You should get “202 Accepted” status code.