Azure Blob Storage – Access Tiers, Lifecycle and Leases · AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage

A .NET application acquires a 30-second lease on an existing block blob and receives leaseId. Another client must not update or delete the blob while…

Practice question from Azure Blob Storage – Access Tiers, Lifecycle and Leases (AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage), with the correct answer and a step-by-step solution.

hard · MCQ · Q-F27155

A .NET application acquires a 30-second lease on an existing block blob and receives leaseId. Another client must not update or delete the blob while the lease is active. Which code correctly uploads new content while honoring the lease?

  1. A.await blobClient.UploadAsync(BinaryData.FromString("new content"), new BlobUploadOptions { Conditions = new BlobRequestConditions { LeaseId = leaseId } });Correct answer
  2. B.await blobClient.UploadAsync(BinaryData.FromString("new content"), new BlobUploadOptions { AccessTier = AccessTier.Cool });
  3. C.await blobClient.SetAccessTierAsync(AccessTier.Cool);
  4. D.await blobClient.DeleteAsync(); await blobClient.UploadAsync(BinaryData.FromString("new content"));

Solution

A write to a blob with an active lease must include the lease ID in the request conditions. BlobRequestConditions.LeaseId supplies that ID. Changing the access tier does not authorize a write, and deleting the blob also requires the lease ID.

More from Azure Blob Storage – Access Tiers, Lifecycle and Leases

All of Azure Blob Storage – Access Tiers, Lifecycle and Leases

Practise more Develop for Azure Storage

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed