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?
- A.await blob.SetMetadataAsync(new Dictionary<string, string> { ["reviewed"] = "true" });
- B.BlobProperties properties = await blob.GetPropertiesAsync(); var metadata = new Dictionary<string, string>(properties.Metadata); metadata["reviewed"] = "true"; await blob.SetMetadataAsync(metadata);Correct answer
- C.await blob.SetTagsAsync(new Dictionary<string, string> { ["reviewed"] = "true" });
- 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
- An ASP.NET Core application uploads a JPEG to Azure Blob Storage. The application must ensure that browsers and download clients recognize…
- A service needs to read a blob's custom metadata key named department without downloading the blob contents. Which code correctly retrieves…
- A catalog service needs to store an arbitrary business value named department on each blob and also specify the blob's MIME type. Which cla…
- A .NET service uploads a JSON document and must set its content type and a custom metadata value during the upload. Which code correctly co…
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 freeFree to start · No credit card needed