Question

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

You are designing a telemetry archival pipeline in C# using the `Azure.Storage.Blobs` SDK. The pipeline processes log files that have an active write lease. You need to transition a specific block blob named `logs_2026.csv` to the Cool access tier and update its custom metadata with a tag of `Status` set to `Archived`. The active lease must not be broken or released during these operations. Which code snippet should you use to successfully update the access tier and metadata of the leased blob?

  1. A
    csharp
    string leaseId = "d5b9f935-862a-436f-87be-23e5124dbf4d";
    var metadata = new Dictionary<string, string>
    {
    { "Status", "Archived" },
    { "x-ms-lease-id", leaseId }
    };

    await blobClient.SetAccessTierAsync(AccessTier.Cool);
    await blobClient.SetMetadataAsync(metadata);
  2. B
    csharp
    string leaseId = "d5b9f935-862a-436f-87be-23e5124dbf4d";
    var metadata = new Dictionary<string, string> { { "x-ms-meta-Status", "Archived" } };

    await blobClient.SetAccessTierAsync(AccessTier.Cool, leaseId: leaseId);
    var conditions = new BlobRequestConditions { LeaseId = leaseId };
    await blobClient.SetMetadataAsync(metadata, conditions);
  3. csharp
    string leaseId = "d5b9f935-862a-436f-87be-23e5124dbf4d";
    var metadata = new Dictionary<string, string> { { "Status", "Archived" } };

    await blobClient.SetAccessTierAsync(AccessTier.Cool, leaseId: leaseId);
    var conditions = new BlobRequestConditions { LeaseId = leaseId };
    await blobClient.SetMetadataAsync(metadata, conditions);
    Answer
  4. D
    csharp
    string sasToken = GetOverPermissionedSasToken(blobClient);
    BlobClient sasBlobClient = new BlobClient(blobClient.Uri, new AzureSasCredential(sasToken));

    await sasBlobClient.SetAccessTierAsync(AccessTier.Cool);
    await sasBlobClient.SetMetadataAsync(new Dictionary<string, string> { { "Status", "Archived" } });

Answer

The correct option is the C# code snippet that provides the lease ID directly to SetAccessTierAsync and via BlobRequestConditions to SetMetadataAsync, using the dictionary key 'Status'.
The correct snippet successfully updates both the access tier and metadata by passing the lease ID in the appropriate parameters required by the Azure SDK for .NET (as a direct parameter to SetAccessTierAsync and via BlobRequestConditions to SetMetadataAsync). It also specifies the metadata key 'Status' without the redundant 'x-ms-meta-' prefix.

Step-by-Step Solution

1
Analyze lease requirements for Blob Storage write operations.
Since the blob is leased, both setting the access tier and updating metadata are write actions that require the active lease ID.
Azure Blob Storage enforces write locks via leases to prevent concurrent modifications.
2
Determine how to pass the lease ID in the Azure SDK for .NET.
For SetAccessTierAsync, the lease ID is passed as a string parameter. For SetMetadataAsync, the lease ID is passed within a BlobRequestConditions object.
The SDK defines different signatures for updating access tiers versus general properties and metadata.
3
Verify metadata naming conventions in the SDK dictionary.
Keys in the metadata dictionary must not contain the 'x-ms-meta-' prefix.
The .NET SDK automatically prepends 'x-ms-meta-' to custom metadata keys during HTTP request serialization.

Key Concept

Modifying leased blob properties, metadata, and access tiers using the Azure SDK for .NET requires specifying the lease ID through distinct parameter signatures without manually adding HTTP metadata prefixes.
Estimated Time:2m 0s
Rate this question