An application needs to assign custom metadata to an Azure Blob Storage container. You write C# code using the Azure.Storage.Blobs SDK (v12) to define the metadata. You want to store a custom key named Environment with the value Production.
Which of the following code snippets correctly defines the metadata dictionary?
- Avar metadata = new Dictionary<string, string>
{
{ "x-ms-meta-Environment", "Production" }
}; - var metadata = new Dictionary<string, string>
{
{ "Environment", "Production" }
};Answer - Cvar metadata = new Dictionary<string, string>
{
{ "x-ms-meta-environment", "Production" }
}; - Dvar metadata = new Dictionary<string, string>
{
{ "metadata-Environment", "Production" }
};
Answer
The correct option is the dictionary that defines 'Environment' as the key directly, without any prefixes, like: new Dictionary<string, string> { { "Environment", "Production" } }.
When using the Azure.Storage.Blobs SDK (v12) in C#, metadata is defined as a standard Dictionary<string, string>. The SDK automatically handles prepending the 'x-ms-meta-' prefix to each key when making the REST API call to Azure Storage. Therefore, you only need to specify the custom key name, such as 'Environment', directly in the dictionary.
Step-by-Step Solution
Key Concept
Azure Storage Blob Metadata SDK Configuration
Estimated Time:45s