title: Identifying scheduled message count using python in azure service bus
body: <p>I am using Python to monitor the status of our Azure Service Bus implementation, and currently using the code below to identify the message count. I use this message count to ensure that the queue is not building up, which could help identify whether the worker role (which consumes from the queue) is not functioning properly.</p>
  
  <pre><code>QueueList = bus_service.list_queues()
  for queue in QueueList:
      queueDetails = bus_service.get_queue(queue.name)
      api.Metric.send(metric="ServiceBus.%s.MessageCount" % (bus_service.service_namespace), points=queueDetails.message_count, host=queue.name)
  </code></pre>
  
  <p>This code works great using the "queueDetails.message_count", and we feed to results to a monitoring tool, provided the messages are active messages and go out immediately. The problem arises when something is scheduled to go out at a later time, and set as a scheduled message not an active message. This throws off our monitoring since it looks like there are messages that were no sent, when in reality they are just delayed. </p>
  
  <p>I have played around with this in powershell, and see that powershell, using the Microsoft.ServiceBus.dll can return a generic "message count", but also, has the ability to break that down into active, scheduled, dead letter, etc.</p>
  
  <p>I know that the python SDK is just a wrapper around the API, but I am wondering if anyone has any ideas, other than "use powershell". Although I am keeping powerhsell in mind as a last resort, I would like to continue using python if possible.</p>
  
  <p>Thanks for your help everyone. Hope this post has enough details. Long time StackOverflow user, first time poster.</p>