Azure Queue Storage · AZ-204: Developing Solutions for Microsoft Azure Connect to and Consume Azure and Third-party Services

A legacy worker reads Azure Queue Storage messages and expects the message body to be Base64-encoded. Which C code configures the Azure.Storage.Queue…

Practice question from Azure Queue Storage (AZ-204: Developing Solutions for Microsoft Azure Connect to and Consume Azure and Third-party Services), with the correct answer and a step-by-step solution.

medium · MCQ · Q-F3635F

A legacy worker reads Azure Queue Storage messages and expects the message body to be Base64-encoded. Which C# code configures the Azure.Storage.Queues client correctly before sending a message?

  1. A.var options = new QueueClientOptions { MessageEncoding = QueueMessageEncoding.Base64 }; var client = new QueueClient(connectionString, "jobs", options); await client.SendMessageAsync("{"id":42}");Correct answer
  2. B.var options = new QueueClientOptions { MessageEncoding = QueueMessageEncoding.None }; var client = new QueueClient(connectionString, "jobs", options); await client.SendMessageAsync("{"id":42}");
  3. C.var client = new QueueClient(connectionString, "jobs"); await client.EncodeMessagesAsync(QueueMessageEncoding.Base64);
  4. D.var client = new QueueClient(connectionString, "jobs"); await client.SendMessageAsync(Convert.FromBase64String("{"id":42}"));

Solution

QueueClientOptions.MessageEncoding controls how the SDK encodes message text. Setting it to QueueMessageEncoding.Base64 makes the client send Base64-encoded message content for compatibility with the legacy worker.

More from Azure Queue Storage

All of Azure Queue Storage

Practise more Connect to and Consume Azure and Third-party Services

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