简体   繁体   English

如何判断Microsoft.WindowsAzure.Storage.DataMovement.TransferManager的CopyDirectoryAsync完成了?

[英]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.

相关问题 如何使用WindowsAzure.Storage.DataMovement? - How to use WindowsAzure.Storage.DataMovement? 我如何判断一个数字何时完成增加? - How can I tell when a number has finished increasing? 如何将字符串转换为 Microsoft.WindowsAzure.Storage.Table.ITableEntity? - How can i convert a string to Microsoft.WindowsAzure.Storage.Table.ITableEntity? NetworkStream.Write 立即返回 - 我如何知道它何时完成发送数据? - NetworkStream.Write returns immediately - how can I tell when it has finished sending data? 如何判断文件是否已完成FTP? - How can I tell if a file has finished being FTPed? 在创建新的HiveConnection时加载Microsoft.WindowsAzure.Storage的例外情况 - Exception from loading Microsoft.WindowsAzure.Storage when creating a new HiveConnection 当包含“ Microsoft.WindowsAzure.Storage”时,C#的Powershell代码不起作用 - Powershell code from C# doesn't work when “Microsoft.WindowsAzure.Storage” is included 我可以使用什么事件处理程序来告诉DataGrid控件何时完成排序? - What event handler can I use to tell when a DataGrid control has finished sorting? Microsoft.WindowsAzure.Storage 是否符合 FIPS 140-2 - Can Microsoft.WindowsAzure.Storage be FIPS 140-2 compliant 关闭 wpf window 时如何判断 await 是否正在运行或已完成运行 - How do I tell if await is running or has finished running when closing wpf window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM