You are developing a background service in C# that uses the .NET Azure.Storage.Blobs SDK to migrate public assets to a secure container. You need to copy a blob named video.mp4 from a public source container to a destination container in your storage account. The copy operation must run asynchronously, and the service must monitor the progress until it is fully completed.
Arrange the steps in the correct order to perform the copy and monitor its status.
- 1Instantiate a BlobServiceClient using the connection string of the destination storage account.
- 2Retrieve a BlobContainerClient for the destination container, and get a reference to the target BlobClient.
- 3Call StartCopyFromUriAsync on the target BlobClient, passing the URI of the public source blob.
- 4Call GetPropertiesAsync on the target BlobClient to fetch the initial copy operation details.
- 5Check the CopyStatus property of the returned properties in a loop until it does not equal CopyStatus.Pending.
Answer
First, instantiate the BlobServiceClient. Next, retrieve the destination BlobContainerClient and get a reference to the destination BlobClient. Then, call StartCopyFromUriAsync on the destination BlobClient using the source URI. Afterward, call GetPropertiesAsync to retrieve the initial status. Finally, poll the CopyStatus property in a loop until it is no longer pending.
The correct sequence begins with creating the client connection, accessing the destination container and blob references, initiating the copy from the source URI, and then polling the status properties until the operation is no longer pending.
Step-by-Step Solution
Key Concept
Asynchronous blob copying and status monitoring using the .NET Azure.Storage.Blobs SDK