Simple Monitoring of Azure Service Bus

I currently have around 20 queues in one of my Azure Service Bus instances, and the messages are being processed by Azure Functions with Service Bus queue triggers.

While Application Insights is great right out the box for visualizing all kind of exceptions and performance issues, one thing I was missing was an easy way of checking how many messages are waiting to be processed, and how many messages has ended up in all the different Dead Letter Queues. Since I already had a Function app for processing the messages, I added another Function triggered by a timer. The function runs every 5 minutes - and then it will read the message count for every queue I have.

I submit the message count over to Application Insights with the Telemetry Client, and suddenly the count is visible without having to click through every single queue in the Azure Portal. I'm hoping Azure Service Bus will push metrics directly to Application Insights in the future, but for now this approach will have to do.