You need to write a C# application using the Azure.Storage.Blobs SDK (v12) to temporarily lock a blob for exclusive write access. Arrange the following steps in the correct order to acquire a 30-second lease, perform operations, and then clean up the lease resource.
- 1Instantiate a BlobClient representing the target blob in your storage account container.
- 2Call GetBlobLeaseClient on the BlobClient instance to initialize a BlobLeaseClient object.
- 3Invoke AcquireAsync on the BlobLeaseClient, specifying a TimeSpan of 30 seconds.
- 4Call ReleaseAsync on the BlobLeaseClient to free the lease once operations are finished.
Cevap
First instantiate a BlobClient, then initialize a BlobLeaseClient using GetBlobLeaseClient, next call AcquireAsync to secure the lease, and finally call ReleaseAsync to unlock the blob.
The correct sequence begins with creating the base BlobClient targeting the blob. Next, you must instantiate a BlobLeaseClient by calling the GetBlobLeaseClient extension method on the BlobClient. Once initialized, AcquireAsync is invoked on the lease client to lock the blob. Finally, after performing modifications, ReleaseAsync is called to free the lock.
Adım Adım Çözüm
Anahtar Kavram
Acquiring and releasing leases using the Azure.Storage.Blobs SDK (v12) BlobLeaseClient.