Writing to an Azure Queue
If you've seen my previous post then this post is quite similar, this time however I write to an Azure Queue and not to a blob.
Code
First of all you need an Azure storage account as before, but once this is set up, consider the following code…
![]()
What I’m doing in the code above is
- Connecting to my storage account
- Creating the queue if it doesn't exist (remember you’ll get a bad request if you don’t name the queue correctly!).
- Then I create a simple message, I’m using a POCO object from another project and serializing it to JSON.
Did it work?
Let’s use VS2013 U3 to check!
![]()
Open your server explorer and select the queue under the storage account you’ve chosen in your connection string, double click.
![]()
Above you see the message added to the queue, you can see how many times it was de-queued and when it’s set to expire. If we use a competing consumer pattern that count may be more than 1!
Next
I’m a little torn re my next post, I’ve been writing a post on C# expression trees which is nearing completion, however I think to keep in line with the current trend I’ll post how this queue can be read and fed to an Azure Service Bus topic (pub/sub)… stay tuned ;-)