Skip to content
Permalink
2 contributors

Users who have contributed to this file

@victorhurdugaci @mathewc
51 lines (42 sloc) 1.4 KB
using System;
using System.Threading;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Queue;
using Newtonsoft.Json;
namespace QueueOperations
{
class Program
{
static void Main()
{
CreateDemoData();
JobHost host = new JobHost();
host.Start();
// Stop the host if Ctrl + C/Ctrl + Break is pressed
Console.CancelKeyPress += (sender, args) =>
{
host.Stop();
};
while(true)
{
Thread.Sleep(500);
}
}
private static void CreateDemoData()
{
string connectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.Storage);
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue queue = queueClient.GetQueueReference("initialorder");
queue.CreateIfNotExists();
Order person = new Order()
{
Name = "Alex",
OrderId = Guid.NewGuid().ToString("N").ToLower()
};
queue.AddMessage(new CloudQueueMessage(JsonConvert.SerializeObject(person)));
}
}
}
You can’t perform that action at this time.