Start-AzureStorageBlobCopy无法复制vhd

时间:2018-09-10 14:53:55

标签: azure powershell azure-storage

代码如下:

$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

我正在将256GB的数据磁盘复制到blob进行DR练习,但失败,并显示以下日志:

[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."

它将创建一个不可用的0字节Blob。这曾经工作过。有谁知道这个错误。我不应该这样做吗?有没有更好的办法?谢谢!

1 个答案:

答案 0 :(得分:1)

我认为由于文件只能使用3600秒而导致上传失败:
$sas = Grant-AzureRmDiskAccess -ResourceGroupName $diskResourceGroup -DiskName $diskName -DurationInSecond 3600 -Access Read

更改文件可读性的时间应该可以解决您的问题。