A developer is writing a service in C# that moves large backup files from a public container to a secure archival container in a different Azure Storage account using the Azure.Storage.Blobs SDK (version 12.x). The operation must execute asynchronously and log a message once the file transfer completes successfully. Place the steps in the correct order to programmatically copy the blob and monitor the progress of the copy operation.
- 1Instantiate a BlobContainerClient targeting the destination storage account container.
- 2Call GetBlobClient on the container client to retrieve a reference to the destination BlobClient.
- 3Invoke StartCopyFromUriAsync on the destination BlobClient, passing the source blob's SAS URI.
- 4Invoke GetPropertiesAsync on the destination BlobClient to retrieve the current operation state.
- 5Check if CopyStatus is Pending and loop, waiting before fetching properties again until it changes.
Cevap
To perform an asynchronous copy operation and monitor it using the Azure.Storage.Blobs SDK, first instantiate the BlobContainerClient for the destination container. Second, retrieve the target BlobClient from that container. Third, call StartCopyFromUriAsync on the destination client with the source SAS URI. Fourth, call GetPropertiesAsync to fetch the current state. Finally, poll the CopyStatus in a loop until it is no longer Pending.
The correct sequence begins with initializing the container client, followed by getting the specific blob client. Next, the copy is triggered from the destination blob client pointing to the source URI. Finally, the status is monitored by fetching the destination blob properties and polling until the copy status leaves the pending state.
Adım Adım Çözüm
Anahtar Kavram
Using Azure.Storage.Blobs SDK to copy blobs asynchronously from a source URI and monitor the copy status.