Windows Azure Storage - required package
Local Storage Emulator - may be installed via Web Platform Installer by installing Microsoft Azure SDK for .NET (latest available at this moment)
var storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true"); // connection string
var queueClient = storageAccount.CreateCloudQueueClient();
var queue = queueClient.GetQueueReference("sandbox"); // queue name
queue.CreateIfNotExists();
queue.AddMessage(new CloudQueueMessage("Hello World!"));
while (true)
{
var message = queue.GetMessage();
if (message != null)
{
//TODO: process message
queue.DeleteMessage(message);
}
else
{
Thread.Sleep(1000);
}
}
- Sample.AddMessages - will start adding messages to queue
- Sample.QueueSize - to monitor how much messages left in queue
- Worker.Code - common code to process messages
- Worker.Console - console worker
- Worker.Service - example of Windows Service