You are developing a C# background service that must safely update the content of an existing blob named config.json in Azure Blob Storage. To prevent concurrency conflicts, your service must lock the blob using a lease before performing the upload and release the lease immediately afterward. You are using the Azure.Storage.Blobs (v12) SDK.
Order the steps required to implement this lease-based upload workflow.
- 1Create a BlobClient instance for the config.json blob.
- 2Instantiate a BlobLeaseClient by calling GetBlobLeaseClient() on the BlobClient.
- 3Call AcquireAsync() on the BlobLeaseClient to lock the blob and receive a lease ID.
- 4Call UploadAsync() on the BlobClient, passing the lease ID inside a BlobUploadOptions object's Conditions property.
- 5Call ReleaseAsync() on the BlobLeaseClient to unlock the blob.
Answer
The correct order of operations is to first create the BlobClient, then instantiate the BlobLeaseClient, acquire the lease, upload the blob content with the lease ID included in the request conditions, and finally release the lease.
To safely modify a leased blob, you must establish client references, acquire the lock to obtain a lease ID, supply that lease ID with the upload request, and release the lock when the operation is complete.
Step-by-Step Solution
Key Concept
Lease management workflow in Azure Storage Blobs C# SDK
Estimated Time:1m 30s