[英]How can I tell when CopyDirectoryAsync from Microsoft.WindowsAzure.Storage.DataMovement.TransferManager has finished?
I am trying to copy many containers from one Azure blob storage account to another blob storage account. 我正在尝试将许多容器从一个Azure Blob存储帐户复制到另一个Blob存储帐户。
I am using the Microsoft.WindowsAzure.Storage.DataMovement
library for C# and the TransferManager.CopyDirectoryAsync
method. 我正在将
Microsoft.WindowsAzure.Storage.DataMovement
库用于C#和TransferManager.CopyDirectoryAsync
方法。
I have no problems discovering all my containers, but when I try and copy a container, I get no feedback about blobs that have been copied. 我发现所有容器都没有问题,但是当我尝试复制容器时,没有收到关于已复制的Blob的反馈。 I want to copy millions of blobs so I want feedback for when this is finished.
我想复制数百万个Blob,因此需要完成时的反馈。 I am using an asynchronous server-side copy, IE
isServiceCopy = true
我正在使用异步服务器端副本,IE
isServiceCopy = true
I am calling 我在打电话
return await TransferManager.CopyDirectoryAsync(sourceDirectory,
destinationDirectory, true, options, null).ConfigureAwait(false);
and since I am awaiting I am expecting it not to pass from this line until the copy is complete. 由于我正在等待,因此我希望它不会在复制完成之前从这一行通过。 But it passes almost immediately, and if I inspect the
NumberOfFilesTransferred
on the TransferStatus
result it is always 0
. 但是它几乎立即通过,如果我检查
TransferStatus
结果上的NumberOfFilesTransferred
,则它始终为0
。 Even if I check the result repeatedly in a while loop this number never changes from 0
. 即使我在while循环中反复检查结果,该数字也不会从
0
更改。 However, if I check in the Azure portal, all the expected files have been copied successfully. 但是,如果我签入Azure门户,则所有期望的文件都已成功复制。
I have also tried setting the ProgressHandler
on DirectoryTransferContext
, and it gets called a few times, but all the properties are 0
. 我也尝试过在
DirectoryTransferContext
上设置ProgressHandler
,它被调用了几次,但是所有属性均为0
。
Does anyone know why I am not getting any feedback from the copy? 有谁知道为什么我没有从副本中得到任何反馈?
Thanks in advance. 提前致谢。 Chris
克里斯
This is incorrect: 这是不正确的:
CloudBlobDirectory sourceDirectory = sourceContainer.GetDirectoryReference(".");
CloudBlobDirectory destinationDirectory = destinationContainer.GetDirectoryReference(".");
Note that Azure Blob Storage doesn't have a real folder hierarchy, the argument here is actually a prefix of the blobs within a blob container. 请注意,Azure Blob存储没有真正的文件夹层次结构,此处的参数实际上是Blob容器中Blob的前缀。 Therefore, please change the code to:
因此,请将代码更改为:
CloudBlobDirectory sourceDirectory = sourceContainer.GetDirectoryReference(string.Empty);
CloudBlobDirectory destinationDirectory = destinationContainer.GetDirectoryReference(string.Empty);
You can poll the CopyState of the blob. 您可以轮询Blob的CopyState 。 For details see https://stackoverflow.com/a/42255582
有关详细信息,请参见https://stackoverflow.com/a/42255582
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.