In my previous blog, I had explained how to add a message in queue. Now here is the sample code to read the message from a queue
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("torageConnectionString"));
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
// Retrieve a reference to a queue
CloudQueue queue = queueClient.GetQueueReference("queueName");
if (!queue.Exists())
continue;//In case queue is not found
//Retrieve message from queue
CloudQueueMessage retrievedMessage = queue.GetMessage();
if (retrievedMessage == null)
continue;//If Message is found null
string message = retrievedMessage.AsString;//Retrieve message in as string
queue.DeleteMessage(retrievedMessage);//After reading the message, we should dequeue it so that it does not come in process again
0 Comment(s)