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?
- A.var options = new QueueClientOptions { MessageEncoding = QueueMessageEncoding.Base64 }; var client = new QueueClient(connectionString, "jobs", options); await client.SendMessageAsync("{"id":42}");Correct answer
- B.var options = new QueueClientOptions { MessageEncoding = QueueMessageEncoding.None }; var client = new QueueClient(connectionString, "jobs", options); await client.SendMessageAsync("{"id":42}");
- C.var client = new QueueClient(connectionString, "jobs"); await client.EncodeMessagesAsync(QueueMessageEncoding.Base64);
- 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
- A .NET worker retrieves a message from Azure Queue Storage and may need up to two minutes to process it. The worker calls ReceiveMessagesAs…
- An Azure Queue Storage worker receives a message, but processing fails repeatedly because the message contains invalid data. The applicatio…
- A long-running .NET worker receives a message using Azure.Storage.Queues and needs to extend the message's invisibility while processing co…
- A .NET application must place a 100 KiB document-related work item in Azure Queue Storage. What is the recommended design?
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 freeFree to start · No credit card needed