Provisioning some test storage accounts for class

I wanted to create a few storage accounts for students in my class to complete an assignment featuring Event Sourcing and Material Views.

So, here’s what I did.

Download/install the latest azure command line interface (cli).
(While doing this, I realized I could have just used the cloud shell. I soldiered on with the dl)

Create a resource group to contain the accounts we’d need.

#Prior to doing this, ensure that user is logged in
# 'az login' works
#Then, if you have multiple subscriptions attached to account, select the appropriate one using:
# 'az account set –subscription <name or id>'
#command below:
az group create –name COMP6905A2Storage #name I used

Create the accounts and output the storage account keys
The command to make a single storage account is pretty straightforward:

#ensure logged in to azure
#ensure default subscription is desired one
az storage account create –name comp69052017a2test \ #test storage account
–resource-group COMP6905A2Storage \#test resource group
–location eastus –sku Standard_LRS \
–encryption blob

But I wanted to also output the keys and display them on a single line. The command to get the keys after the account is created is this:

az storage account keys list –account-name comp69052017a2test –resource-group COMP6905A2Storage

So, I used the jq program in bash to parse the json result and display both keys on a line. Thus, I created a script that would create the accounts and then output their storage account keys.
This is the script that produced the accounts and keys:

for number in {1..20}
az storage account create –name $account –resource-group COMP6905A2Storage –location eastus –sku Standard_LRS –encryption blob | jq ".name"
az storage account keys list –account-name $account –resource-group COMP6905A2Storage | jq '.[].value' | tr -s '\n' ','

Overall, the longest part of the exercise was dealing with the way the files were being saved in windows vs how they were being saved and read by bash. But the accounts were created and class can get on with assignment 2.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s