Blob metadata is not saved even though I call CloudBlob.SetMetadata
I see that this question is quite old and in the meantime, I guess, the API has changed.
Now, if you want to fetch metadata then you need to use BlobTraits.Metadata option in the following snippet:
await foreach (BlobItem item in containerClient.GetBlobsAsync(BlobTraits.Metadata))
{
var name = item.Name;
var meta = item.Metadata;
}
SetMetadata should work as expected. But simply getting a reference to the blob isn't sufficient to read the metadata.
After getting the blob reference, you need to call the FetchAttributes method on that CloudBlob. This will load all properties and metadata, and only then will you be able to access the metadata you set previously:
// Get a reference to a blob.
CloudBlob blob = blobClient.GetBlobReference("mycontainer/myblob.txt");
// Populate the blob's attributes.
blob.FetchAttributes();
// Enumerate the blob's metadata.
foreach (var metadataKey in blob.Metadata.Keys)
{
Console.WriteLine("Metadata name: " + metadataKey.ToString());
Console.WriteLine("Metadata value: " + blob.Metadata.Get(metadataKey.ToString()));
}