'Not all those who wander are lost' - J.R.R Tolkien

Connecting to Windows Azure Storage through PowerShell

I came across this paper describing the Windows Azure Storage design here.

And with that, I stopped thinking about Windows Azure Storage as as an extended file system and started thinking of it as a distributed, highly available, noSql persistence layer provided by the Azure platform.

That changes things quite a bit.

Windows Azure Storage - not an extended file system.

It provides all three of Consistency, Availability and Partition tolerance, which apparently violates CAP, but has actually been made possible through some heavy lifting as detailed in the paper.

It offers five different sorts of distributed data services

Only problem, is, all of this through the Azure Portal is a lot of clicks. Now, all Azure services offer REST apis, and PowerShell access. So, let's see if all those clicks can be mutated into key-strokes, logging into and accessing Windows Azure Storage through PowerShell commands.

A short but important note.

After a while of fiddling around with Azure PowerShell commands, you will find that there are two versions of almost everything.

Login-AzureAccount vs Login-AzureRmAccount

Get-AzureStorageAccount vs Get-AzureRmStorageAccount

This non Rm and Rm options indicate Azure operational models before and after there was a Azure concept called resource group. A resource group is a logical grouping of Azure physical services - viz. storage, VMs, etc.

To read more, look here and here.

In our case, we need to be conscious that wherever there is a choice, we need to go with the Rm versions.

Setting Up PowerShell for Windows Azure

For a fresh machine, we need to have the AzureRM package installed. On an elevated (Administrator) prompt

Azure Credentials for PowerShell Session

Close the current PS prompt and open a non-elevated one.

And that is it. We are all set.

Working with Azure Storage Accounts

Create

To create a Azure Storage Account

New-AzureRmStorageAccount -ResourceGroupName $your-resource-group -Name "your-storage-acc-name" -Location $yourDefinedlocation -SkuName Standard_LRS -Kind Storage -EnableEncryptionService Blob

View

To access all the storage accounts for your MSDN account, try this -

Get-AzureRmStorageAccount -ResourceGroupName "your-resource-group" -AccountName "account-name" | Select StorageAccountName

You should see your StorageAccountName on your console, including the one created above.

Delete

To remove a storage account, the following applies -

Remove-AzureRmStorageAccount -ResourceGroupName "your-resource-group" -AccountName "your-storage-account"

From here on, PowerShell commands should enable you to do almost anything with an Azure Storage Account you can do over REST or .NET libraries. All we need to do is explore.