Azure Blob Storage – SDK, Properties and Metadata · AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage

A service needs to read a blob's custom metadata key named department without downloading the blob contents. Which code correctly retrieves the metad…

Practice question from Azure Blob Storage – SDK, Properties and Metadata (AZ-204: Developing Solutions for Microsoft Azure Develop for Azure Storage), with the correct answer and a step-by-step solution.

medium · MCQ · Q-6ABE34

A service needs to read a blob's custom metadata key named department without downloading the blob contents. Which code correctly retrieves the metadata?

  1. A.BlobProperties properties = await blob.GetPropertiesAsync(); string department = properties.Metadata["department"];Correct answer
  2. B.BlobDownloadResult result = await blob.DownloadContentAsync(); string department = result.Value.Content.ToString();
  3. C.IReadOnlyDictionary<string, string> department = await blob.GetTagsAsync();
  4. D.string department = blob.Uri.Query["department"];

Solution

GetPropertiesAsync retrieves the blob's system properties and user-defined metadata without downloading the content. The metadata is available through the returned BlobProperties.Metadata dictionary. Blob index tags are separate from metadata.

More from Azure Blob Storage – SDK, Properties and Metadata

All of Azure Blob Storage – SDK, Properties and Metadata

Practise more Develop for Azure Storage

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed