8

I'm using Azure Queue to send emails. But for last time I'm getting exception about queue size limit up to 65536 bytes even after cheking the message size.

enter image description here

David Makogon
  • 69,407
  • 21
  • 141
  • 189
Roman Borovets
  • 818
  • 12
  • 25

2 Answers2

18

While it is true that the maximum size of a message can be 64KB however Azure uses UTF16 encoding to store the data thus for each byte of data that you provide, Azure Storage uses 2 bytes to store that data.

What this means is that you can essentially store up to 32KB of data in a message in an Azure Queue. Because you're exceeding this 32KB limit, you're getting this error.

Gaurav Mantri
  • 128,066
  • 12
  • 206
  • 241
  • 1
    There're many things you could do other than reducing the message size: 1) One way to reduce the message size is to apply some kind of compression on the message contents. However there're always a possibility that even after compression you may exceed this 32 KB limit 2) Store the message contents in blob storage and message will contain the blob URL. Then when you need to get the message, you simply fetch the blob from that URL. Since a blob can be of 200GB in size, I don't think you will run into the issue of 32KB limit. – Gaurav Mantri Sep 16 '16 at 11:24
  • 1
    Or you could use a Service Bus https://azure.microsoft.com/en-us/documentation/articles/service-bus-azure-and-service-bus-queues-compared-contrasted/ – Flemin Adambukulam Sep 16 '16 at 11:30
2

A string message will be Base64 encoded before being sent thus increasing its length by about a third.

Therefore the maximum length of message string you can submit is 49152 which equates to 65536, the maximum allowed.

The formula for calculating the Base64 encoded length can be found here: https://stackoverflow.com/a/13378842/5836877

Matias Kinnunen
  • 7,828
  • 3
  • 35
  • 46
JamesP
  • 95
  • 1
  • 9
  • Is this the reason when I try to put a fairly large JSON message in a queue in the Azure Portal, the check mark “Encode the message in the body in Base64” gets grayed out? – Oliver Nilsen Oct 07 '22 at 19:42