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?
- Acsharp
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); - Bcsharp
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); - 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 - Dcsharp
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
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