You are developing a C# backend application that uses the Azure.Storage.Blobs SDK (v12) to manage resources in Azure Blob Storage. A blob contains custom metadata with a key named `ProjectOwner`.
You retrieve the properties of the blob using the following code:
csharp
BlobProperties properties = (await blobClient.GetPropertiesAsync()).Value;
Which code segment should you use to retrieve the value of the `ProjectOwner` custom metadata key?
- Astring owner = properties.Metadata["x-ms-meta-ProjectOwner"];
- Bstring owner = properties.Metadata["x-ms-meta-projectowner"];
- string owner = properties.Metadata["ProjectOwner"];Answer
- Dstring owner = properties.Metadata["X-Ms-Meta-ProjectOwner"];
Answer
The correct code segment is: string owner = properties.Metadata["ProjectOwner"];
The correct answer correctly queries the dictionary using the key name without the 'x-ms-meta-' prefix. In the Azure.Storage.Blobs SDK, the HTTP response headers are parsed, and the metadata keys are mapped directly into a dictionary with the prefix removed.
Step-by-Step Solution
Key Concept
Retrieval of custom blob metadata via the C# SDK without HTTP header prefixes
Estimated Time:1m 0s