Search code examples
c#.net-standardazure-queuesazure-storage-queues

Message Text in Azure Queue is encoded, how do I remove this encoding?


When I add something to the queue, messageText becomes encoded, how do i remove it so that it is in clear text?

See the message text in the queue here

enter image description here

var queueClient = new QueueClient(ConnectionString, "paymentfiles2");
var r = await QueueClient.SendMessageAsync("Demo")

I use Azure.Storage.Queues, Version=12.4.2.0 in .NET Standard 2.0 project


Solution

  • By default, QueueClient.SendMessageAsync sends the text in UTF8 encoding. But Azure portal assumes it as Base64, that's why it shows like garbage value. But if you use Storage Explorer, you have the option of selecting encoding like below.

    When I used await QueueClient.SendMessageAsync("Demo"): enter image description here enter image description here

    But you do have the option of sending it in Base64 like below so that Azure portal shows it correctly and also to retain same behavior as older package WindowsAzure.Storage.

    So when I used below code, portal shows correctly:

    await QueueClient.SendMessageAsync(Convert.ToBase64String(Encoding.UTF8.GetBytes("Demo")))

    enter image description here