Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
azure cli command to create a resource group, storage account, and storage container
az group create --name Terraform-Remote-State-Group --location "East US"
# the above command creates a resource group and displays the result in below format
"id": "/subscriptions/$(SubscriptionNumber)/resourceGroups/Terraform-Remote-State-Group",
"location": "eastus",
"managedBy": null,
"name": "Terraform-Remote-State-Group",
"properties": {
"provisioningState": "Succeeded"
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
# Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only.
# The below command creates a storage account with the name "terraformremoteskundu". The storage account name has to be globally unique
# else you get the message (StorageAccountAlreadyTaken) The storage account named terraform is already taken.
az storage account create --resource-group "Terraform-Remote-State-Group" --name "terraformremoteskundu" --sku Standard_LRS --encryption-services blob
# Once the storage account is created, list the access key with the below command. The output of the command is the access key
az storage account keys list --resource-group "Terraform-Remote-State-Group" --account-name "terraformremoteskundu" --query [0].value -o tsv
# The below command creates a storage container with the name "tfstate"
az storage container create --name "tfstate" --account-name "terraformremoteskundu" --account-key "$(copy_access_key_here)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment