Intro

In the previous post I have showed how to work with append blobs. In this post I am going to cover properties and metadata of blobs, containers and Azure Blob service.

Prerequisites

Refer to previous posts to get started with Azure Blob Service.

Code

Lets start with properties of CloudBlobClient. Consider the following example:

var blobClient = storageAccount.CreateCloudBlobClient();
blobClient.DefaultRequestOptions.LocationMode = LocationMode.SecondaryOnly;
var stats = blobClient.GetServiceStats();
Console.WriteLine(stats.GeoReplication.Status);
Console.WriteLine(stats.GeoReplication.LastSyncTime);

This code prints service stats for the secondary location. It is possible to get such properties as CORS rules using GetServiceProperties method.

Containers have properties and metadata that can be useful in certain situations:

var container = blobClient.GetContainerReference("testcontainer");
container.CreateIfNotExists(BlobContainerPublicAccessType.Blob);
Console.WriteLine(container.Properties.ETag);
Console.WriteLine(container.Properties.LastModified);

This code outputs ETag and LastModified properties.

Blobs have more properties, but I have already covered most important properties such as BlobType.

Both containers and blobs have metadata. The metadata is stored in the Metadata dictionary. Consider the following example:

container.FetchAttributes();
container.Metadata.Add("key1", "value1");
container.SetMetadata();

It loads metadata from server and then adds a single key to it. It is very simple to manage the container metadata. There are many use-cases where container-level storage can be used.

Summar

In this post I have described properties and metadata of Azure Blob Service. In the next post I am going to show how to integrate Azure Content Delivery Network (CDN) with Azure Blob Service.


;