You are developing a C# console application that updates the metadata of a block blob in Azure Blob Storage. The application uses the Azure.Storage.Blobs SDK (version 12). To prevent other processes from modifying the blob during the update, you must acquire a write lease on the blob, perform the metadata update, and then release the lease.
Which five actions should you perform in sequence? To answer, arrange the actions in the correct order.
- 1Instantiate a BlobClient for the target Azure Blob Storage block blob.
- 2Create a BlobLeaseClient using the BlobClient instance.
- 3Call AcquireAsync on the BlobLeaseClient to obtain a write lease on the blob.
- 4Call SetMetadataAsync on the BlobClient with a BlobRequestConditions object containing the acquired lease ID.
- 5Call ReleaseAsync on the BlobLeaseClient to unlock the blob.
Answer
To perform a leased metadata update, you first instantiate a BlobClient, then create a BlobLeaseClient from it, acquire the lease, call SetMetadataAsync using a BlobRequestConditions containing the lease ID, and finally call ReleaseAsync to release the lease.
The correct sequence starts with instantiating a BlobClient to reference the blob. Next, a BlobLeaseClient is created from the BlobClient. The lease is then acquired using AcquireAsync. Once the lease is active, SetMetadataAsync is called with BlobRequestConditions containing the lease ID. Finally, the lease is released using ReleaseAsync.
Step-by-Step Solution
Key Concept
Acquiring a write lease, updating blob metadata with request conditions, and releasing the lease using the Azure SDK for .NET.