8

There are several ways to copy azure blob storage blocks around. There's a synchronous and asynchronous version of StartCopy. There is also a BeginStartCopy which also has the completion callback.

The BeginStartCopy approach explicitly states that the callback is executed when the copy has completed.

The StartCopy approaches both state that they return a string, which is a copy process id - they don't state that they return when the copy has completed.

Do those StartCopy methods return after the actual copy has completed?

Ryan
  • 7,733
  • 10
  • 61
  • 106

1 Answers1

13

Both StartCopy() and await StartCopyAsync() return when the copy is started on Azure Blob Storage service. The completion callback of BeginStartCopy() is also executed when the copy is started on Azure Blob Storage service.

In conclusion, StartCopy (including all 3 versions above) is an asynchronous API, you need to call FetchAttributes() periodically by yourself to get the latest copy progress.

Here is an answer that you can refer to: https://stackoverflow.com/a/47651946/2995449

Zhaoxing Lu
  • 6,319
  • 18
  • 41
  • 1
    "The completion callback of `BeginStartCopy()` is also executed when the copy is *started*"? Is that a typo? As OP mentions, the documentation clearly states that the callback is notified upon completion of the operation. – Isaac Kleinman Apr 03 '19 at 16:31
  • 2
    @IsaacKleinman It's NOT a typo. The callback is notified upon the completion of **StartCopy**, rather than the completion of **Copy**. – Zhaoxing Lu Apr 04 '19 at 03:22
  • Is this still true if both source and destination for the copy are in the same storage account? [This documentation](https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-copy?tabs=dotnet11#about-copying-blobs) mentions that under the same storage account copying is a synchronous operation. – Chris H. Jan 19 '22 at 23:34