Determining how many messages are on the Azure Service Bus Queue

aceinthehole picture aceinthehole · Apr 27, 2013 · Viewed 20k times · Source

I know there is a way to determine the number of messages (or approximate number) in the Azure Queue (Store Account); however is there a way to query for the number of pending messages on an Azure Service Bus queue?

Answer

Joseph picture Joseph · Feb 16, 2014
var nsmgr = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(connectionString);
long count = nsmgr.GetQueue(queueName).MessageCount;