Soru

Zorluk: ZorManage Properties, Metadata, and Access Tiers for Azure Blob Storage

You are developing a C# application that manages document archiving using the Azure.Storage.Blobs SDK (version 12). You write the following helper method to process and archive blobs:

csharp
public static async Task ArchiveBlobAsync(BlobClient blobClient, string user)
{
// Retrieve existing properties
BlobProperties properties = (await blobClient.GetPropertiesAsync()).Value;

// Check if the blob has a classification
if (properties.Metadata.ContainsKey("Classification"))
{
Console.WriteLine($"Classification: {properties.Metadata[\"Classification\"]}");
}

// Add the archival metadata
var metadata = new Dictionary<string, string>
{
{ "ArchivedBy", user }
};
await blobClient.SetMetadataAsync(metadata);

// Transition the blob to the Cool tier
await blobClient.SetAccessTierAsync(AccessTier.Cool);
}

Which of the following statements regarding the behavior or issues in this code are correct? (Select TWO)

  1. The check properties.Metadata.ContainsKey("Classification") will evaluate to false even if a metadata key named "Classification" exists on the blob, because Azure Blob Storage returns metadata keys in lowercase.Cevap
  2. Calling SetMetadataAsync(metadata) will clear all existing custom metadata on the blob, leaving only the "ArchivedBy" metadata key.Cevap
  3. C
    To read the metadata key correctly, the code must check for the "x-ms-meta-Classification" key because the SDK retains the HTTP header prefix in the Metadata dictionary.
  4. D
    The SetMetadataAsync method will automatically bypass any active exclusive-write leases on the blob without requiring a lease ID, because metadata updates do not modify the actual binary content of the blob.

Cevap

The check for the 'Classification' key will evaluate to false because keys are returned in lowercase, and calling SetMetadataAsync will overwrite and delete all existing metadata on the blob.
The correct statements identify that metadata keys are returned in lowercase by the storage service, causing case-sensitive checks for 'Classification' to fail, and that SetMetadataAsync replaces the entire metadata collection, which deletes any existing metadata not included in the input dictionary.

Adım Adım Çözüm

1
Analyze metadata retrieval behavior in the .NET SDK via GetPropertiesAsync.
The Metadata dictionary keys are populated in lowercase because Azure Blob Storage returns them as lowercase HTTP headers.
Checking for uppercase keys like 'Classification' using ContainsKey will return false.
2
Analyze metadata update behavior via SetMetadataAsync.
The call replaces the entire metadata collection with the new dictionary.
All existing custom metadata keys not included in the new dictionary will be deleted.
3
Verify lease and access tier conditions.
Updating metadata on a leased blob requires specifying the lease ID, and setting the access tier does not bypass this requirement if a lease is present.
Ensures correct understanding of concurrency and access tier operations.

Anahtar Kavram

Managing Blob properties, metadata, and access tiers in C# using the Azure SDK.
Bu soruyu puanla