Warning!! Technical post ahead. If you’re not an ITPro or Developer you’re going to bored to tears by this article so here’s something else to read which is quite funny.
Tonight I’m trying to create an Azure VM via Powershell using the New-AzureQuickVM cmdlet and I’m getting an error involving CurrentStorageAccountName. Remember the days of manually configuring a virtual machine, loading images from CDs etc? Now it’s just a single command:
New-AzureQuickVM -Windows -ServiceName $s -Name $n -AdminUsername $aUn -Password $Pw -Location $l -InstanceSize $is -ImageName $I
I ran into a problem right away that I’m writing about in this blog concerning an error message that wasn’t very clear to me:
I couldn’t find anything in the documentation concerning access required to a storage account. My assumption was a default account would be created or an existing one used. After awhile I tried “Get-Azuresubscription -current” and noticed this (sidenote–if it isn’t obvious, I’ve masked a lot of unique IDs with strings of X’s to keep my subscription private):
So that’s when things became obvious. I was asking Azure to create a VM for me but I didn’t have a place for Azure to put it when it was done. So how to correct the problem? Two simple steps.
The first is to create a storage account in the region where you’re putting the VM. In my case, that was the “South Central US” region:
The last step to correct the problem is to associate my subscription with this new storage account. When I associate the storage account with my subscription, any Powershell command requiring a place to store blob data will use this associated storage account. To do so we run set-azuresubscription:
..and to confirm our change took effect run “Get-Azuresubscription -current” again and notice the CurrentStorageAccountName is populated with the storage account we just created:
Lastly, now that we have the CurrentStorageAccountName set we re-run New-AzureQuickVM to create our virtual machine and receive the expected result:
A few minutes later I’ve got a running VM ready for a workload, just by running the single Powershell command New-AzureQuickVM.
From a devops/architect/developer/itpro/geek perspective Interacting with Azure happens three ways:
- Web portal. There’s two of these right now. Here and here. The latter frequently links back to the former because it’s not 100% finished yet.
- REST API. Lots to see here. The Azure Reference is a good place to get your feet on the ground.
- Powershell. The last time I checked there are more than 1100 different Powershell cmdlets available for download.
I recommend bookmarking this link: https://azure.microsoft.com/en-us/downloads/ All of the various tools, utilities and updates are always published there and have been for quite some time.