Search code examples
c#.netazureazureservicebus

How many messages have passed through Azure Service Bus during the last minute?


I want to programmatically know how many messages were posted/retrieved from the queue during the last minute. Azure portal allows viewing this: enter image description here

I want to get the same data in my application for further analysis. It would be better to have this info for the last day but knowing value just from now on will also work. I know how to get the current count of messages from the MessageCountDetails class, but this is not the same thing.


Solution

  • I want to programmatically know how many messages were posted/retrieved from the queue during the last minute. Azure portal allows viewing this

    You can do that using Monitor Service API. The new .NETSTD client doesn't provide an equivalent to the .NETFX MessageCountDetails, so I've put together a sample how to retrieve metrics using Monitor Service API you could use as a starting point.