AZURE

Adding message in a Windows Azure Queue

In this post I will show you code snippet to add message in azure queue. I have written a function returning Boolean value and taking string input parameter to add as message in queue.

Create instance of cloud storage account

image

Create a client of azure queue

image

Get the reference of particular queue. Create queue if does not exist

image

Add message to queue

image

For your reference full source code is given below,


public bool AddMessageinQueue(string MessageToAdd, string QueueName)
{
try
{
CloudStorageAccount account = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("DataConnectionString"));
CloudQueueClient queueClient = account.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference(QueueName);
queue.CreateIfNotExist();

CloudQueueMessage m = new CloudQueueMessage(MessageToAdd);
queue.AddMessage(m);


return true;


}
catch (Exception ex)
{
return false;
}
}

 

 

In this way you can add message in azure queue. I hope this post was useful. Thanks for reading Smile

If you find my posts useful you may like to follow me on twitter http://twitter.com/debug_mode or may like Facebook page of my blog http://www.facebook.com/DebugMode.Net If you want to see post on a particular topic please do write on FB page or tweet me about that, I would love to help you.

About Dhananjay Kumar

Dhananjay Kumar is Developer, Blogger , Speaker, Learner , Mindcracker & Microsoft MVP.

Discussion

Trackbacks/Pingbacks

  1. Pingback: Monthly Report September 2011: Total Posts 28 « debug mode…… - October 1, 2011

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,380 other followers

Tweets

Categories

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my current or previous employer's view in anyway. © Copyright 2012