I’ve been trying to create a Virtual Machine in the Azure with the Azure cmdlets.
The error calling New-AzureQuickVM was:
New-AzureQuickVM: CurrentStorageAccount is not set. Use Set-AzureSubscription subname -CurrentStorageAccount storageaccount to set it.
The script which was supposed to create it was:
Import-Module "D:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1" Import-AzurePublishSettingsFile –PublishSettingsFile $publishingFileName Set-AzureSubscription -SubscriptionName $subscriptionName -CurrentStorageAccount $storageAccountName New-AzureQuickVM -Windows -Location "West Europe" -ServiceName $cloudSvcName -Name $vmName -ImageName "MSFT__Windows-Server-2012-Datacenter-201210.01-en.us-30GB.vhd" -Password $adminPassword -InstanceSize ExtraSmall Start-AzureVM -ServiceName $cloudSvcName -Name $vmName
The point is, that I had multiple subscriptions imported with the same name and there is only ONE default.
Running the Get-AzureSubscription shows us at which subscription the IsDefault:true. And of course I’ve been setting the CurrentCloudStorage always to the wrong subscription.
To overcome the problem I did the following steps:
- I’ve opened the publishsettings xml file and renamed my subscription
- Imported it again with the
Import-AzurePublishSettingsFile –PublishSettingsFile $publishingFileName
- Called the
Set-AzureSubscription -DefaultSubscription subscriptionName
- And then I could call the
Set-AzureSubscription -SubscriptionName $subscriptionName -CurrentStorageAccount $storageAccountName