Skip to content

Instantly share code, notes, and snippets.

@kunduso
Last active March 26, 2021 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunduso/70bb5e869a349d3d6c3a5ff2dbe9589c to your computer and use it in GitHub Desktop.
Save kunduso/70bb5e869a349d3d6c3a5ff2dbe9589c to your computer and use it in GitHub Desktop.
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