Question

Difficulty: MediumManage Properties, Metadata, and Access Tiers for Azure Blob Storage

A C# application updates the custom metadata of an Azure Blob Storage block blob that has an active write lease. You are using the Azure.Storage.Blobs SDK (version 12) to add a metadata key-value pair of 'status' and 'processed'. Which of the following actions are required to complete this operation successfully without triggering exceptions? (Select TWO)

  1. Pass the lease ID within a BlobRequestConditions object to the SetMetadataAsync method.Answer
  2. Exclude the x-ms-meta- prefix from the key name in the metadata dictionary.Answer
  3. C
    Include the x-ms-meta- prefix as part of the key name in the metadata dictionary.
  4. D
    Call SetMetadataAsync without specifying a lease ID, since leases only restrict binary content changes.

Answer

To successfully update the metadata of a leased blob, you must pass the lease ID within a BlobRequestConditions object to the SetMetadataAsync method, and you must exclude the x-ms-meta- prefix from the metadata dictionary key names.
Updating metadata on a leased blob requires verifying ownership of the lease by passing the lease ID in a BlobRequestConditions object to the SetMetadataAsync method. Additionally, the SDK automatically prepends the required 'x-ms-meta-' header prefix to keys in the metadata dictionary, so developers must define keys without this prefix.

Step-by-Step Solution

1
Identify the lease status of the target blob.
Since the blob is leased, any metadata update requires authentication of the lease.
An active lease blocks metadata updates unless the lease ID is supplied.
2
Create a BlobRequestConditions object and set its LeaseId property.
A BlobRequestConditions instance is prepared with the active lease ID.
This object is passed as a parameter to SetMetadataAsync to authorize the modification.
3
Populate the IDictionary<string, string> with metadata keys.
The metadata dictionary contains 'status' rather than 'x-ms-meta-status'.
The Azure.Storage.Blobs SDK automatically prefixes metadata keys with x-ms-meta- during transmission.

Key Concept

Updating metadata on leased blobs requires passing the active lease ID using BlobRequestConditions and specifying dictionary keys without the x-ms-meta- prefix.
Rate this question