Anand
Anand

Reputation: 1123

Start-AzureStorageBlobCopy fails to copy vhd

Here is the code:

$sas = Grant-AzureRmDiskAccess -ResourceGroupName $diskResourceGroup -DiskName $diskName -DurationInSecond 3600 -Access Read

$storageAccountKey = (Get-AzureRmStorageAccountKey -Name $storageAccount -ResourceGroupName $storageAccountResourceGroup)[0].Value
$destContext = New-AzureStorageContext -StorageAccountName $storageAccount -StorageAccountKey  $storageAccountKey

$checkContainer = Get-AzureStorageContainer -prefix $blobContainerName -Context $destContext

Start-AzureStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer $blobContainerName -DestContext $destContext -DestBlob $blobName -Force
Get-AzureStorageBlobCopyState -Container $blobContainerName -Blob $blobName -Context $destContext -WaitForComplete

I'm copying a 256GB data disk to blob for DR exercises and it fails with the following log:

[18:44:22][Step 7/12] Start Copy of VM to storage [18:44:23][Step 7/12] [18:44:23][Step 7/12] ICloudBlob : Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob [18:44:23][Step 7/12] BlobType : PageBlob [18:44:23][Step 7/12] Length : -1 [18:44:23][Step 7/12] ContentType : [18:44:23][Step 7/12] LastModified : 9/8/2018 10:44:22 PM +00:00 [18:44:23][Step 7/12] SnapshotTime : [18:44:23][Step 7/12] ContinuationToken : [18:44:23][Step 7/12] Context : Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext [18:44:23][Step 7/12] Name : some-data-disk.vhd [18:44:23][Step 7/12] [19:43:50][Step 7/12] [19:43:50][Step 7/12] CopyId : 36d3af59-ce10-4e7c-9b98-cb7ab50d1bb7 [19:43:50][Step 7/12] CompletionTime : 9/8/2018 11:43:49 PM +00:00 [19:43:50][Step 7/12] Status : Failed [19:43:50][Step 7/12] Source : https://md-zdj0tc3ldgbq.blob.core.windows.net/px2lhh4 [19:43:50][Step 7/12] e75-b63db649096c&sig=NsbVUO5+LQoUnIvCFMKJcKYSJ9DlI7m/ [19:43:50][Step 7/12] BytesCopied : 75310645760 [19:43:50][Step 7/12] TotalBytes : 274877907456 [19:43:50][Step 7/12] StatusDescription : 403 AuthenticationFailed "Copy failed when reading [19:43:50][Step 7/12] the source."

It creates a 0 byte blob that is unusable. This used to work before. Does anyone have insight into this error. Should I not be doing this? Is there a better way? Thanks!

Upvotes: 0

Views: 1071

Answers (2)

Bailey Lawson
Bailey Lawson

Reputation: 36

I believe the upload is failing due to the fact the file is only available for 3600 seconds:
$sas = Grant-AzureRmDiskAccess -ResourceGroupName $diskResourceGroup -DiskName $diskName -DurationInSecond 3600 -Access Read

Changing the amount of time that the file is readable for should solve your problem.

Upvotes: 2

Joy Wang
Joy Wang

Reputation: 42043

But according to the amount of data backed up, it should take this script 4 hours to back up my drive. Is there a better/faster method?

In this case, you could try to use Azcopy to copy blobs in Blob storage. For very large amounts of data, you can also Azure Import/Export.

Moving Data FAQ in official doc:

Can I migrate VHDs from one region to another without copying?

Upvotes: 1

Related Questions