A C# financial auditing application needs to update the custom metadata on an existing block blob containing a transaction ledger. To prevent concurrent write operations from other clients, the application must implement lease-controlled metadata updates using the Azure SDK for .NET. Which of the following sequences represents the correct order of steps the application must execute to perform this update securely?
- 1Instantiate a `BlobClient` object pointing to the target ledger block blob.
- 2Instantiate a `BlobLeaseClient` associated with the `BlobClient` and call `AcquireAsync` to secure a lease.
- 3Call `GetPropertiesAsync` on the `BlobClient`, providing a `BlobRequestConditions` object populated with the lease ID.
- 4Call `SetMetadataAsync` on the `BlobClient` with the new metadata dictionary and the `BlobRequestConditions` containing the active lease ID.
- 5Call `ReleaseAsync` on the `BlobLeaseClient` to free the lock on the blob.
Answer
The correct order of operations begins with instantiating a `BlobClient` to reference the target blob. Next, a `BlobLeaseClient` is created and `AcquireAsync` is invoked to secure a lease. Once the lease is acquired, `GetPropertiesAsync` is called with the lease ID in the request conditions to read the current state. Afterward, `SetMetadataAsync` is executed with the updated metadata and the lease ID in the request conditions. Finally, the lease is released using `ReleaseAsync` on the lease client.
The correct order requires establishing the client connection first, obtaining a write lock (lease) to ensure concurrency control, fetching the current properties under that lease, applying the metadata change using the lease ID, and finally releasing the lease so others can access the blob.
Step-by-Step Solution
Key Concept
Lease-controlled blob operations in Azure Blob Storage using the .NET SDK.
Estimated Time:2m 0s