PowerShell to Automate Azure Storage Account Creation

Why would you want to click through a portal for 30 minutes if you could just create everything programmatically? That's what inspired me to write some code. Getting Powershell setup is easy:

http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/

Here is the output from running the provisioning process:

image001

Figure 1: Provisioning Storage Accounts

The code is crazy easy, as long as you remember the storage account name needs to be lower case. You'll get a weird error if you forget that.

Getting data center locations is easy

The command is Get-AzureLocation

image002

Figure 2: The awesome PowerShell IDE

You will get all the data centers and capabilities with one command. How awesome is that?

image003

Figure 3: The Output of Get-AzureLocation

Provisioning PowerShell Code

Provisioning Storage Accounts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 $DataCenterList = \@(             ,\@("terkalysoutheastasia", "Southeast Asia")             ,\@("terkalyenortheurope", "North Europe")             ,\@("terkalyeastus", "East US")             ,\@("terkalywestus", "West US")             ,\@("terkalyjapaneast", "Japan East")             ,\@("terkalycentralus", "Central US")         ) ForEach($DC in $DataCenterList) {     Write-Host("Provisioning " + $DC[1]);     Write-Host(" Description " + $DC[0]);     Start-Sleep -s 1     New-AzureStorageAccount -StorageAccountName $DC[0] -Location $DC[1] }

Conclusion

It is really that easy to loop through an array and provision storage accounts all over the world.