How do you explicitly abandon a message in a azure function triggered from a topic message/subscription?

Viewed 988

Im using an azure function which is invoked every time a new message is published to a topic + SUBSCRIPTION ( NOT a queue!)

What exactly do I need to do within the azure function body to EXPLICITLY move it to the dead letter subqueue?

According to azure,

Exceeding MaxDeliveryCount Queues and subscriptions each have a QueueDescription.MaxDeliveryCount and SubscriptionDescription.MaxDeliveryCount property respectively; the default value is 10. Whenever a message has been delivered under a lock (ReceiveMode.PeekLock), but has been either explicitly abandoned or the lock has expired, the message BrokeredMessage.DeliveryCount is incremented. When DeliveryCount exceeds MaxDeliveryCount, the message is moved to the DLQ, specifying the MaxDeliveryCountExceeded reason code.

From a c# code perspective , What exactly do they mean by

"explicitly abandoned or the lock has expired"

Im only talking about topic/subscription here. Please no comments on service bus queues, just topic/subcription. (even if the logic is the same, I'm only interested in treating topic/subscription here. talking about services bus queues is just going to confuse the focus of the question)

1 Answers

You cannot explicitly dead-letter a message from an Azure Function. The function will dead-letter messages after going through all the retries. Explicit dead-lettering is possible when using a C# client and implementing custom receiving logic.

BTW, subscription or queue, it doesn't matter. They both are queues.

Related