I am trying to add a VHD image from my local filesystem to Azure BLOB storage. Whenever I do this after about 6 minutes I get the error "The remote server returned an error: (400) Bad Request". I use the following steps to upload the image (using Azure Resource Manager):
PS C:\Users\myuser> Set-AzureRmContext -SubscriptionId aaaaaaaa-bbbb-cccc-dddd-0123456789012
Environment : AzureCloud
Account : [email protected]
TenantId : aaaaaaaa-bbbb-cccc-dddd-0123456789012
SubscriptionId : aaaaaaaa-bbbb-cccc-dddd-0123456789012
SubscriptionName : MySubscription
CurrentStorageAccount :
PS C:\Users\myuser>
PS C:\Users\myuser> $rgName = "MyResourceGroupName"
PS C:\Users\myuser> $urlOfUploadedImageVhd = "https://myblobaccount.blob.core.windows.net/myvirtualmachine.vhd"
PS C:\Users\myuser>
PS C:\Users\myuser> Add-AzureRmVhd -ResourceGroupName $rgName -Destination $urlOfUploadedImageVhd -LocalFilePath C:\Users\myuser\myvirtualmachine.vhd
MD5 hash is being calculated for the file C:\Users\myuser\myvirtualmachine.vhd.
MD5 hash calculation is completed.
Elapsed time for the operation: 00:06:29
Creating new page blob of size 136365212160...
Add-AzureRmVhd : The remote server returned an error: (400) Bad Request.
At line:1 char:1
+ Add-AzureRmVhd -ResourceGroupName $rgName -Destination $urlOfUploaded ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureRmVhd], StorageException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.StorageServices.AddAzureVhdCommand
I have no idea how to debug this further? I would very much appreciate any help in finding out what is going wrong.
Your Azure Storage Account type is "Blob Storage". According to docs, it doesn't do page blobs, which are required for VMs.
Fix this by uploading into a General Purpose storage account. More info in my blog.
Add -Debug switch to see the actual REST calls.
It might help to try manually uploading a page blob on the azure portal website to find the cause of the issue. For a VHD you need a page blob. Note that these are not supported on zone redundant storage accounts. More details can be found here.