- Containers support system properties and user-defined metadata
- System properties:
- System properties exist on each Blob storage resource.
- Some of them can be read or set, while others are read-only.
- Under the covers, some system properties correspond to certain standard HTTP headers.
- User-defined metadata:
- User-defined metadata consists of one or more name-value pairs that you specify for a Blob storage resource.
- You can use metadata to store additional values with the resource.
- Metadata values are for your own purposes only, and do not affect how the resource behaves.
- Metadata name/value pairs are valid HTTP headers, and so should adhere to all restrictions governing HTTP headers.
- Metadata names must be valid HTTP header names and valid C# identifiers, may contain only ASCII characters, and should be treated as case-insensitive.
- Metadata values containing non-ASCII characters should be Base64-encoded or URL-encoded.
Retrieve container properties
- To retrieve container properties, call one of the following methods of the
BlobContainerClient
class:
- GetProperties
- GetPropertiesAsync
// Fetch some container properties and write out their values.
var properties = await container.GetPropertiesAsync();
Console.WriteLine($"Properties for container {container.Uri}");
Console.WriteLine($"Public access level: {properties.Value.PublicAccess}");
Console.WriteLine($"Last modified time in UTC: {properties.Value.LastModified}");
- To set metadata, add name-value pairs to an IDictionary object, and then call one of the following methods of the BlobContainerClient class to write the values:
- SetMetadata
- SetMetadataAsync
IDictionary<string, string> metadata = new Dictionary<string, string>();
// Add some metadata to the container.
metadata.Add("docType", "textDocuments");
metadata.Add("category", "guidance");
// Set the container's metadata.
await container.SetMetadataAsync(metadata);
var properties = await container.GetPropertiesAsync();
// Enumerate the container's metadata.
Console.WriteLine("Container metadata:");
foreach (var metadataItem in properties.Value.Metadata)
{
Console.WriteLine($"\tKey: {metadataItem.Key}");
Console.WriteLine($"\tValue: {metadataItem.Value}");
}