Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add message to azure storage queue without base64 encoding?

I don't have the possibility to encode my request to base64, and according to the documentation I shouldn't have to, but I can't figure it out.

If I Base64 encode it's working fine:

<QueueMessage>
<MessageText>PHNhbXBsZT5zYW1wbGUgbWVzc2FnZTwvc2FtcGxlPg==</MessageText>
</QueueMessage>

Which adds the decoded message to the queue:

<sample>sample message</sample>

According to the documentation (https://msdn.microsoft.com/sv-se/library/azure/dd179346.aspx)

A message must be in a format that can be included in an XML request with UTF-8 encoding. To include markup in the message, the contents of the message must either be XML-escaped or Base64-encode. Any XML markup in the message that is not escaped or encoded will be removed before the message is added to the queue.

Trying to add (instead of PHNhbXBsZT5zYW1wbGUgbWVzc2FnZTwvc2FtcGxlPg==):

&lt;sample&gt;sample message&lt;/sample&gt;

Succeeds but when trying to view the message in the queue it only responds with:

The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.

Does somebody know how send a proper raw xml-escaped request message to the storage queue?

Full request (without keys and names):

POST https://xxxxxxx.queue.core.windows.net/testqueue/messages?sv=2015-04-05&ss=q&srt=sco&sp=a&se=2026-11-11T20:24:03Z&st=2016-11-11T12:24:03Z&spr=https&sig=xxxxxxxxxxxxxxxxx%3D HTTP/1.1
User-Agent: Fiddler
Host: XXXXX.queue.core.windows.net
Content-Type: text/plain
Content-Length: 64

<QueueMessage>
<MessageText>&lt;sample&gt;sample message&lt;/sample&gt;</MessageText>
</QueueMessage>
like image 924
thllbrg Avatar asked Nov 11 '16 15:11

thllbrg


People also ask

What is the difference between Azure storage queue and service bus queue?

Storage queues provide a uniform and consistent programming model across queues, tables, and BLOBs – both for developers and for operations teams. Service Bus queues provide support for local transactions in the context of a single queue.

Is the message size limit in a Azure storage queue 32 KB 64 KB 1 MB 128 KB?

Azure documentation states that Storage queue message cannot exceed 64 KB.


1 Answers

John Donnelly answer. is now out of date. CloudQueue is now considered legacy and you should be using QueueClient instead. QueueClient does not have an EncodeMessage property but you can specify the MessageEncoding when injecting the service:

builder.Services.AddAzureClients(builder => {
      builder.AddQueueServiceClient(<connection string>)
         .ConfigureOptions(o => o.MessageEncoding = QueueMessageEncoding.None);
}
like image 106
Liam Avatar answered Sep 20 '22 19:09

Liam