An Azure integration workflow must modify the metadata of a blob while preventing write conflicts. Using the .NET SDK (`Azure.Storage.Blobs`), write operations to the blob must be temporarily locked.
Order the steps required to programmatically lock the blob, apply the metadata changes, and release the lock.
- 1Call the `GetBlobLeaseClient` extension method on a `BlobClient` instance to generate a helper client for lease operations.
- 2Invoke `AcquireAsync` on the lease client to obtain a write lock and generate the corresponding lease ID.
- 3Invoke `SetMetadataAsync` on the `BlobClient` while passing the lease ID inside a `BlobRequestConditions` object.
- 4Invoke `ReleaseAsync` on the lease client to terminate the write lock and allow other clients to modify the blob.
Answer
The correct sequence begins by instantiating a lease client using GetBlobLeaseClient, followed by acquiring the lease using AcquireAsync. Next, SetMetadataAsync is invoked on the BlobClient with the acquired lease ID supplied within BlobRequestConditions, and finally, the lease is freed by calling ReleaseAsync on the lease client.
To modify a blob safely under a concurrency lock, a client must first obtain a BlobLeaseClient to coordinate lease actions. Second, the lease must be explicitly acquired to retrieve the lease ID. Third, the metadata update is committed using the lease ID inside BlobRequestConditions. Finally, the lease must be released to clean up the lock and make the blob available to other clients.
Step-by-Step Solution
Key Concept
Acquiring, using, and releasing a lease during blob metadata modifications to prevent concurrency issues using the Azure Storage SDK.