I try to upload a vhd to azure (fixed size of 30GB), but it always gives me an error after the end of upload.
Before that, I have imported my publish settings file, I set as default my subscritption and I set the default storage to vhds
Add-AzureVhd -Destination "https://*****.blob.core.windows.net/vhds/vm.vhd" -LocalFilePath "C:\Users\****\Desktop\vm.vhd"
MD5 hash is being calculated for the file C:\Users\****\Desktop\vm.vhd.
MD5 hash calculation is completed.
Elapsed time for the operation: 00:02:59
Creating new page blob of size 32212255232...
Add-AzureVhd : The remote server returned an error: (400) Bad Request.
At line:1 char:1
+ Add-AzureVhd -Destination "https://*****.blob.core.windows.net/vhds ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AzureVhd], StorageException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Storage.StorageException,Microsoft.WindowsAzure.Commands.ServiceM
anagement.StorageServices.AddAzureVhdCommand
Do you have any idea on how to troubleshoot that?
Here are some ideas to troubleshoot. I have just tried your same challenge without problems.
First, I think your error pops up before the upload. Because the whole process looks like this. And it seems that your error pops up right after the try to create a new blob. After that comes a lengthy process where the empty spaces of the VHD are detected.
PS C:\Users\pkirch> Add-AzureVhd -LocalFilePath 'C:\Hyper-V\Virtual Hard Disks\test30gb.vhd' -Destination "https://webdavsvr.blob.core.windows.net/vhds/test30gb.vhd"
MD5 hash is being calculated for the file C:\Hyper-V\Virtual Hard Disks\test30gb.vhd.
MD5 hash calculation is completed.
Elapsed time for the operation: 00:02:58
Creating new page blob of size 32212255232...
Detecting the empty data blocks in the local file.
Detecting the empty data blocks completed.
Elapsed time for upload: 00:00:00
LocalFilePath DestinationUri
------------- --------------
C:\Hyper-V\Virtual Hard Disks\test30gb.vhd https://webdavsvr.blob.core.windows.net/vhds/test30gb.vhd
Some while ago I posted a script to upload a VHD on GitHub Gist. Have a look if you're not missing a step. Those are mainly:
# Settings $SubscriptionName = "Azure MSDN - pkirchner" $StorageAccountName = "pkteststorageaccount" $Container = "vhds" $LocalVhd = "C:\Users\pkirch\fixedvhd20mb.vhd" # Select my Microsoft Azure Subscription. Select-AzureSubscription -SubscriptionName $SubscriptionName # Create new storage account. New-AzureStorageAccount -Location "West Europe" -StorageAccountName $StorageAccountName -Type Standard_LRS # Create container for VHDs. $StorageAccountKey = Get-AzureStorageKey -StorageAccountName $StorageAccountName New-AzureStorageContext -StorageAccountKey $StorageAccountKey.Primary -StorageAccountName $StorageAccountName | ` New-AzureStorageContainer -Name $Container -Permission Off # Add-AzureVhd needs the CurrentStorageAccountName to be set. Set-AzureSubscription -SubscriptionName $SubscriptionName -CurrentStorageAccountName $StorageAccountName # Build destination path automatically. $NewContainer = Get-AzureStorageContainer -Name $Container $VhdFile = Split-Path -Path $LocalVhd -Leaf $Destination = $NewContainer.CloudBlobContainer.Uri.AbsoluteUri + "/" + $VhdFile # Upload VHD Add-AzureVhd -Destination $Destination -LocalFilePath $LocalVhd
Second, if you're not missing any steps, I would try to look for errors using Fiddler. Using Fiddler with PowerShell for Azure is not straightforward. Here is blog post how to do it.