Hi there,
I recently used the Start-AzureStorageBlobCopy power-shell command to move some VHD images for a VM between two storage accounts in separate subscriptions (from our pay-as-you-go to our MSDN subscription).
The VM associated with the VHDs (one OS disk and two Data Disks) were not attached to the VM since the VM had been previously deleted. There were however some disks that were still created that referenced the blobs which I suspect may have held a lease on the disk blobs.
After running the following command to copy the blobs from the source storage account to the destination storage account, everything appeared to succeed.
Start-AzureStorageBlobCopy
-SrcContainer $containerName
-SrcBlob "MyVM.vhd"
-Context $srcContext
-DestContainer $containerName
-DestBlob "MyVM.vhd"
-DestContext $destContext
But, when I now attempt to create new Disks in the destination subscription storage account from the copied blobs the following error is displayed:
Add-AzureDisk : "An exception occurred when calling the
ServiceManagement API. HTTP Status Code: 400. Service Management
Error Code: BadRequest. Message: The blob is not a valid VHD..
Operation Tracking ID: c5116bbb92944ee8affa20fe0e1839c0."AtC:\...\Scripts\CopyBlobsBetweenStorageAccounts.ps1:44 char:1+
Add-AzureDisk -DiskName 'MyVM' -MediaLocat ... + CategoryInfo :
CloseError: (:) [Add-AzureDisk],
ServiceManagementClientException + FullyQualifiedErrorId :
Microsoft.WindowsAzure.Management.ServiceManagement.IaaS.AddAzureDiskCommand
After searching for a solution I came across this article which mentions that if a Lease is held on the file and a copy is performed, the resulting blob copy will be invalid. Why was I even able to copy a invalid file in the first place?
Unfortunately, I had deleted the source blobs before testing the restore (I know... rookie mistake) and now I am unable to create new Disks from the copied blobs to recreate the VM because I always get the invalid blob error message above. I am using the following command to try and recreate Disks from the blobs:
Add-AzureDisk
-DiskName 'MyVM'
-MediaLocation "http://???.blob.core.windows.net/vhds/MyVM.vhd"
-Label 'MYVM-OS'
-OS Windows
Is there a way to work around this problem or did I hose myself after prematurely deleting the original blobs from the source storage account?
Thanks
Richard