title: Azure Service Bus Queues: How To Read Individual Messages From A Queue
body: <p>I have an application where I am able to write a message to an Azure Service Bus Queue in a JSON format in one part of my process.  I have a downstream process that I'd like to then pop that message off the queue, translate the json to an object and then process that object.  </p>
  
  <p>I have no problem pushing messages onto the queue but I have not been able to find any examples of popping a message off of the queue one at a time or in a loop.  EVERY example that I've seen from Microsoft or on Github is a console application (useless in a web application) that sets up some kind of listener that grabs all the messages in a queue and writes a console message.  There are no examples I've found where the message is popped and then some processing is done with the data.  Does anyone have examples on how to pop a message off of the queue and then process it or call another method to do something with the data in the message?  </p>
  
  <p><strong>Update:</strong>
  I used the WindowsAzure.ServiceBus example below supplied by Guru Pasupathy and ended using the following snippet from <a href="https://stackoverflow.com/questions/61977591/azure-service-bus-queues-how-to-read-individual-messages-from-a-queue/61982454?noredirect=1#comment109647013_61982454">Azure Service Bus Queues: How To Read Individual Messages From A Queue</a> to get the text of the message from the BrokeredMessage object:  </p>
  
  <pre><code>Stream stream = message.GetBody&lt;Stream&gt;();
  StreamReader reader = new StreamReader(stream);
  string messageBody =  reader.ReadToEnd();
  </code></pre>
  
  <p>I could then take messageBody and deserialize the embedded JSON into a POCO object and I was on my way!  Now I can use queues more effectively in my application for a variety of tasks.  </p>