Azure / azure-functions-python-worker

Python worker for Azure Functions.
http://aka.ms/azurefunctions
MIT License
331 stars 100 forks source link

Null Message Body Reprocessing Messages from Service Bus Subscription #1516

Open TylrRssll opened 5 days ago

TylrRssll commented 5 days ago

Affects models V1 and V2 and the latest available library version.

Service Bus Subscription

Question

We are encountering an issue that Azure support has not been able to help with so hopefully we may obtain an answer here.

We have a simple azure function using the latest python library version that when reading specific messages from a service bus subscription the body of the message is returning as null. The messages in question have been re-sent to the service bus topic from the dead letter queue as the original invocation of the function failed after reading the message body but the failure reason is unrelated to the issue I am reporting.

When the message is re-sent from the DLQ of the subscription to the topic the azure function will fire, the first command executed is

message.get_body().decode("utf-8")

When executed the body returned is null, however when viewing the message in service bus explorer prior to the function reading the message the body contains valid JSON.

What we have established is that if the topic has large message support enabled (max message size 10MB rather than the default 1MB), if a message is resent from the DLQ to the subscription, the body when read in the azure function using the snippet above is null, if the topic does not have large message support enabled the message body is NOT null.

After significant investigation a colleague of mine has found that the message published directly to the topic using any means (programmatically or via the azure portal service bus explorer) has a message body type of AmqpMessageBodyType.DATA but when the same message is re-sent from the DLQ and subsequently read by the azure function the message body type is AmqpMessageBodyType.VALUE.

My suspicion is that the get_body() method does not work as expected when the message body type is AmqpMessageBodyType.VALUE and thus returns a NULL.

Lastly the azure support team that provides support for the service bus service will no longer provide support on the issue as they claim as the message body is visible in service bus explorer the issue must lie with the azure functions sdk.