1

This link mentions about storing and retrieving metadata at container level. I was just wondering if its possible to set and retrieve metadata about a blob stored in a directory inside that container?

1 Answer 1

1

I was just wondering if its possible to set and retrieve metadata about a blob stored in a directory inside that container?

Yes, you can certainly do so. Please see the sample code below:

        const string ConnectionString = "DefaultEndpointsProtocol=https;AccountName=account-name;AccountKey=account-key";
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConnectionString);

        //Create the service client object for credentialed access to the Blob service.
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

        // Retrieve a reference to a container.
        CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

        CloudBlockBlob blob = container.GetBlockBlobReference("images/logo.png");
        blob.FetchAttributes();//Gets the properties & metadata for the blob.
        blob.Metadata.Add("Key", "Value");
        blob.SetMetadata();//Saves the metadata.
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I am glad I checked this post again coz I was disheartened when you initially said that it was not possible.
Sorry....my bad! I read the post incorrectly. I thought you wanted to set metadata on the folder. Once I reread the question, I realized my mistake and edited my answer. Sorry about that!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.