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

A .NET service uploads a JSON document and must set its content type and a custom metadata value during the upload. Which code correctly configures t…

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-356E9B

A .NET service uploads a JSON document and must set its content type and a custom metadata value during the upload. Which code correctly configures the upload?

  1. A.var options = new BlobUploadOptions { HttpHeaders = new BlobHttpHeaders { ContentType = "application/json" }, Metadata = new Dictionary<string, string> { ["source"] = "orders" } }; await blob.UploadAsync(stream, options);Correct answer
  2. B.var options = new BlobUploadOptions { Tags = new Dictionary<string, string> { ["ContentType"] = "application/json", ["source"] = "orders" } }; await blob.UploadAsync(stream, options);
  3. C.await blob.SetMetadataAsync(new Dictionary<string, string> { ["ContentType"] = "application/json", ["source"] = "orders" }); await blob.UploadAsync(stream);
  4. D.await blob.UploadAsync(stream, new BlobUploadOptions { Metadata = new Dictionary<string, string> { ["ContentType"] = "application/json", ["source"] = "orders" } });

Solution

BlobUploadOptions.HttpHeaders configures HTTP properties, and BlobUploadOptions.Metadata configures custom metadata. ContentType should not be represented as metadata or a tag.

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