Azure – Issues uploading VHD in Azure Powershell with Add-AzureVHD commandlet

azureazure-storagepowershell

I'm attempting what should be a pretty basic task. I've created a local VHD of a workstation template that I want to upload for use in my Azure environment. I'm working from Azure Powershell.

I've uploaded my .cer file to create a management certificate. I've imported the .publishsettings file and I'm able to use Set-AzureSubscription and Select-AzureSubscription with no apparent issues:

Set-AzureSubscription -SubscriptionName "Windows Azure Enterprise" -CurrentStorageAccount ATOQA

Select-AzureSubscription -SubscriptionName "Windows Azure Enterprise"

The problem I run into is this when I attempt to use Add-AzureVHD:

PS C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-10\bin> add-azurevhd -destination "https://ATOQA.blob.core.windows.net/vhds/ztemplate-W7.vhd" -localfilepath "C:\VM\W7_Template\ztemplate-w7.vhd"
add-azurevhd : "An exception occurred when calling the ServiceManagement API. HTTP Status Code: 404. Service Management Error Code: ResourceNotFound. Message: The requested storage account 
'atoqa' was not found.. Operation Tracking ID: df91c24901254047b39a7a7d5b037ea0."
At line:1 char:1
+ add-azurevhd -destination "https://ATOQA.blob.core.windows.net/vhds/ztemplate-W7 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Add-AzureVhd], ServiceManagementClientException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.StorageServices.AddAzureVhdCommand

I'm fairly certain that the information I'm using to specify the -destination is correct, since I've copied it directly from the container URL field on the Azure site.

Where am I going wrong? I've been using a few websites as guides to give you an idea of what I've been working from:

http://www.cloudtec.ch/blog/tech/upload-vhd-to-azure.html

http://msdn.microsoft.com/en-us/library/windowsazure/dn205185.aspx

I've also attempted to use CSUPLOAD with the same basic steps and get a message that states "storage account was not found", leading me to believe i'm populating a parameter with the wrong information, but I'm really confused on what my mistake is exactly.

Many, many thanks in advance!

Best Solution

Short Answer:

Please ensure that your storage account is in the same subscription as specified in Set-AzureSubscription.

Long Answer:

What's happening (I think) is that when you call Set-Subscription, the cmdlet doesn't check if the storage account is in the same subscription. Now when you call, Add-AzureVhd and specify the destination URL, the cmdlet need to find the storage account key and makes use of Get Storage Account Keys operation for that making use of subscription id and management certificate. Because this storage account does not exist in the specified subscription, you get Resource Not Found error.

Related Question