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

A blob already has metadata keys department and retention. A job must add the metadata key reviewed while preserving the existing keys. Which code pe…

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.

hard · MCQ · Q-03CF7D

A blob already has metadata keys department and retention. A job must add the metadata key reviewed while preserving the existing keys. Which code performs this operation correctly?

  1. A.await blob.SetMetadataAsync(new Dictionary<string, string> { ["reviewed"] = "true" });
  2. B.BlobProperties properties = await blob.GetPropertiesAsync(); var metadata = new Dictionary<string, string>(properties.Metadata); metadata["reviewed"] = "true"; await blob.SetMetadataAsync(metadata);Correct answer
  3. C.await blob.SetTagsAsync(new Dictionary<string, string> { ["reviewed"] = "true" });
  4. D.await blob.SetHttpHeadersAsync(new BlobHttpHeaders { ContentType = "true" });

Solution

SetMetadataAsync replaces the blob's complete metadata collection; it does not append only the supplied entries. The existing metadata must therefore be read, copied, updated, and written back. Blob tags and HTTP headers are different features.

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