Skip to content

Instantly share code, notes, and snippets.

@Fleid
Last active December 25, 2019 17:37
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 Fleid/3dae2fdec2a6496df4ebd1e7794f9bc8 to your computer and use it in GitHub Desktop.
Save Fleid/3dae2fdec2a6496df4ebd1e7794f9bc8 to your computer and use it in GitHub Desktop.
Azure CLI script to provision a resource group and a storage account - see https://www.eiden.ca/asa-alm-102/
# Using Bash (WSL if Windows)
bash
# Login to Azure
az login
# If necessary (multiple subscriptions available), select the appropriate one
az account list --output table
az account set --subscription "mySubscriptionNameGoesHere"
# Set variables (bash syntax)
_location="canadacentral"
_suffix="staging"
_datecreated=`date +"%Y%m%d"`
_rg_name="rg-asatest"
_rg_name+=$_suffix
_sa_name="saasatest"
_sa_name+=$_suffix
_sa_container="container001"
# Create a resource group (look at these tags!)
az group create --location $_location --name $_rg_name --tags 'createdby=somebodyNice' 'datecreated='$_datecreated 'environment=sta' 'purpose=stream-processing'
# Create a storage account
az storage account create \
--name $_sa_name \
--resource-group $_rg_name \
--location $_location \
--sku Standard_LRS \
--encryption blob \
--kind StorageV2
# Get the key of that storage account to create a storage container later
_key1=$(az storage account keys list -g $_rg_name -n $_sa_name --query '[0].value' -o tsv)
# Create a storage container
az storage container create --account-name $_sa_name --account-key $_key1 --name $_sa_container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment