Jason Haley

Ramblings from an Independent Consultant

DevBoston–WebJobs In Depth

The powerpoint presentation for Thursday night’s presentation can be found here: DevBoston-AzureWebJobs.pptx

Here is the Producer-Consumer demo code.  I’m still surprised that it takes so little code to do this:

using Microsoft.Azure.WebJobs;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProducerConsumer
    class Program
        static void Main(string[] args)
            var config = new JobHostConfiguration();


            var host = new JobHost(config);

    public static class Functions
        public static int counter = 0;

	// Create a new message on the "orders" queue every 10 seconds
        public static void Producer(
            [TimerTrigger("00:00:10", RunOnStartup=true)] TimerInfo timer,
            [Queue("orders")] out string messageCount,
            TextWriter log)
            messageCount = "message" + counter++;

            log.WriteLine("messsage: " + messageCount);

	// Watch the "orders" queue for messages, and when one is found save it to blob storage
        public static void Consumer(
            [QueueTrigger("orders")] string message,
            [Blob("orders/order.txt")] out string order,
            TextWriter log)
            order = message;

            log.WriteLine("Received " + message);
Comments are closed