You are writing a C# console application using the Azure.Storage.Blobs SDK (version 12.x) to migrate archive data from a source Azure Storage account to a destination storage account. The source container is private, and you want to perform the transfer asynchronously while monitoring the process. Arrange the following steps in the correct sequence to copy the blob and determine when the operation finishes.
- 1Generate a Shared Access Signature (SAS) token with read (r) permission for the source blob.
- 2Instantiate a BlobContainerClient representing the destination container.
- 3Call GetBlobClient on the destination container client to obtain a BlobClient for the target blob.
- 4Call StartCopyFromUriAsync on the destination BlobClient, passing the source blob's URI with the appended SAS token.
- 5Call GetPropertiesAsync on the destination BlobClient in a loop and check the CopyStatus property until it is no longer Pending.
Answer
Generate the read-only SAS token for the source blob, instantiate the destination BlobContainerClient, obtain the destination BlobClient, initiate the copy using StartCopyFromUriAsync with the source URI, and poll the destination properties until the CopyStatus completes.
To copy a private blob asynchronously between storage accounts, you must first generate a read-only SAS token for the source blob. Next, create a container client and then a blob client for the destination target. With these clients set up, call StartCopyFromUriAsync on the destination blob client to prompt the service to pull data from the source URI. Finally, poll the destination properties using GetPropertiesAsync to monitor the copy status until it resolves.
Step-by-Step Solution
Key Concept
Asynchronous Blob Copying using the Azure.Storage.Blobs SDK
Alternative Method
Instead of polling the destination blob properties programmatically, you can listen to Microsoft.Storage.BlobCreated events using Azure Event Grid to handle completion reactively.
Estimated Time:2m 0s