Herman Kan
Herman Kan

Reputation: 2292

Azure service bus trigger function: determine if current attempt is the last one

Before a service bus queue message is moved to a DLQ, I need to clean up some resources associated with the message. Obviously the message's DeliveryCount should be compared with the queue's MaxDeliveryCount to determine if this is the last attempt or not. How can I get the MaxDeliveryCount from within an Azure function?

Upvotes: 1

Views: 879

Answers (1)

Jdresc
Jdresc

Reputation: 688

You can use the Service Bus admin client and get it through the MaxDeliveryCount property Admin client

using Azure.Messaging.ServiceBus.Administration;
var adminclient = new ServiceBusAdministrationClient(yourconnectionstring);
QueueProperties runtime = await adminclient.GetQueueAsync(queuename);
Console.WriteLine("Max delivery count is" + runtime.MaxDeliveryCount);

Upvotes: 1

Related Questions