A developer uploads a blob to Azure Blob Storage and configures its metadata using the Azure.Storage.Blobs SDK (v12) for C# with the following code:
csharp
var metadata = new Dictionary<string, string>
{
{ "Department", "Finance" }
};
await blobClient.SetMetadataAsync(metadata);
Later, the developer retrieves the properties of the blob using the following code:
csharp
BlobProperties properties = await blobClient.GetPropertiesAsync();
Which code segment should the developer use to successfully retrieve the metadata value "Finance"?
- Astring department = properties.Metadata["Department"];
- string department = properties.Metadata["department"];Cevap
- Cstring department = properties.Metadata["x-ms-meta-department"];
- Dstring department = properties.Metadata["x-ms-meta-Department"];
Cevap
string department = properties.Metadata["department"];
The correct answer uses the lowercase key 'department'. The Azure Storage REST API returns custom metadata as HTTP headers with the 'x-ms-meta-' prefix, converting key names to lowercase. The Azure.Storage.Blobs SDK automatically strips the 'x-ms-meta-' prefix but leaves the keys lowercased. Since the standard .NET Dictionary used for properties.Metadata is case-sensitive, the lookup must match the lowercase format exactly.
Adım Adım Çözüm
Anahtar Kavram
Azure Blob Storage SDK metadata naming casing rules and prefix stripping