Jason Haley

Ramblings from an Independent Consultant

Talk: Practical WebJobs SDK and Extensions

Thursday night I presented at the Boston Azure user group.  My talk was “Practical WebJobs SDK and Extensions” to a mixed group of people with Azure and WebJobs experience and some who didn’t have any experience with Azure yet.

My deck is here: Practical WebJobs SDK and Extensions.pptx

My demo script is here: Practical WebJobs SDK and Extensions – Demo Script.pdf

The zip of all prepped demos and the live demo folder (the one we created in the talk) are her: Demos.zip

The Cheat Sheet that I referred is here: Azure WebJobs SDK Cheat Sheet 2014.pdf

Boston Azure Bootcamp 2016

This year for the Azure Bootcamp I presented Azure WebJobs and Websites.  We spent more time on the WebJobs topic and hands on lab than we did with the web sites lab.  The websites talk was the last of the day … and its really hard to get people to do a hands on lab late on a Saturday after being there all day.

For anyone who is interested in my material (presentations, hands on labs and code) – it is all in the https://github.com/JasonHaley/BostonAzureBootcamp2016Material github repository.

I really tried to focus on some real world useful topics with the Webjobs HOL … and of course, I’ve been recommending it to people I’ve been working with that are just learning what they can do with WebJobs.

The WebJob HOL (and the included code) includes the following sections:

  1. Create a Console Application project for the WebJob functionality
  2. Setup a storage account to use with the WebJob
  3. Add a function to the WebJob to watch a queue for Orders and then save to Blob storage
  4. Add a test function to verify the queue and blob logic works
  5. Modify the logic to use a custom NameResolver
  6. Modify the logic to use a custom trace writer
  7. Add functionality to save the Products to a storage table
  8. Add functionality to send an email once the order is processed
  9. Add a function to handle poison messages on the Orders queue to send out an email
  10. Add a function that emails when a certain number of error have happened
  11. Deploy the WebJob to Azure

If anyone uses it and has any suggestions or feedback, please let me know.

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);

Boston Code Camp 25 Notes and Resources

Yesterday I gave two presentations at Boston Code Camp 25, here are some notes and resources from my talks.

6+ Years After Going Independent (https://www.bostoncodecamp.com/CC25/Sessions/Details/16336)

This is always a fun talk for me to give – and a real easy one to prepare for.  Yesterday’s audience was the biggest I’ve had so far at a code camp for this talk.  

Here’s the 10 points I covered in the talk:

  1. First a word about FTE vs. being Independent
  2. Know how much you need to make a month to pay your bills
  3. Have 3 – 6 months living expenses in savings always
  4. Setup a business entity LLC, S-Corp or C-Corp
    1. ~$500 a year for LLC in MA
  5. Get a commercial bank account for the business
    1. Checking
    2. Credit Card
    3. Always use business account for business purposes
    4. Stay Organized (Quicken or Quickbooks)
  6. Get an accountant
  7. Get a lawyer
    1. Contract
    2. NDA
  8. Build a brand
  9. Consultant vs. Contractor
  10. Finding work
    1. Build your expertise
    2. Network
    3. Repeat

The power point can be found here: GoingIndependent6.pptx

WebJobs in Depth (https://www.bostoncodecamp.com/CC25/Sessions/Details/16335)

This presentation was much better than trying to split an hour on both Web Sites and Web Jobs.  However I did not get a chance to practice the whole talk a couple of times like I really wanted to.

I did get to present at least 4 ways of deploying web jobs and got to show simple demos of triggers from both the Web Jobs SDK and the Web Jobs SDK Extensions.

This Thursday I’ll be able to extend this talk more for DevBoston (http://www.meetup.com/DevBoston/events/229688772/)

The power point can be found here: AzureWebJobs.pptx

Geek Dinner Feb 16, 2016 - 6:30pm - 8:30pm Boston Beer Works, Canal Street

Are you up for a Geek dinner Tuesday 16th of February from 6:30 – 8:30 or so?

Unless something is going on we’ll be upstairs by the pool tables in Boston Beer Works on Canal Street (1 block from North Station/TD Garden) like usual. 

I’ll post any last minute changes on the twitter feeds: @haleyjason and @BostonGeekDinne (couldn’t fit the r didn’t know about the 15 char limit).

Studying for the Azure Solutions Architect Certification

One of my professional goals this year is to get the Azure Solutions Architect Certification.  I’ve been using Azure for a long time (since before the silverlight portal) and now I figure it is time to have Microsoft certify that I know something … besides that I want to follow the study guides to explore some of the parts that I don’t have so much experience with (like networking and some usages of the virtual machines).

This month (January) I started studying for the 70-532 Developing Microsoft Azure Solutions exam.  So far I am on schedule to take the exam either the 3rd or 4th week of February.

I have collected quite a few links for study material – which I plan on aggregating into a blog post soon.

First I am focusing on the material covered in the exam – but I know I am going to need to start brushing up on my exam taking skills soon too.

Anyone else out there also studying for these exams this year?

Working on a new presentation–Webjobs in depth

This week, I’m working on an abstract/outline for a new Webjobs talk for the next Boston Code Camp (April 2, 2016).

At the last Boston Code Camp, I presented Azure Websites and Webjobs.  Covering both of those topics in a single talk doesn’t allow you to get into as much detail as I like to see technical presentations get.  So, this time around I want to dive deeper into just webjobs.

Things I’d like to see in a detailed webjobs talk:

  • Overview of types of webjobs and how to create
    • Including file system/directory structure
    • Special files and their meanings
  • Overview of Kudu and its role in webjobs
  • Intro to WebJobs SDK
  • Code examples of a few of the WebJobs SDK bindings and triggers
  • Info on WebJobs SDK extensions
  • Simple example of writing your own extension (also want to put a singular presentation together for this topic)

Problem is – time limit will most likely be between 60- 90 min.  So I’ll need to figure out what I can fit into that time limit.

Does anyone have something else they would like to see in the session?

Personal Blog Update - Q1 2016

It has now been more than 6 years since we moved back from Seattle, when I decided to not get another “real job” and instead give “"being an independent consultant” a try.  A lot has happened in that time … and I have shared very little of it (good and bad) in this blog.

Last year I restarted this blog, threw away all the link blog history and planned on creating a great source of content for others to consume … that plan failed.  It failed due to me raising the bar on the level of quality for the content I wanted to provide.  I wanted it to be article/whitepaper worthy material – a complete change from the previous content I had provided before.  To me that meant: I needed code samples, screen shots and real world problems to describe before I could put a blog together.  In looking back at 2015, the real world problems happened (that would have been great blog posts), but I couldn’t get past the time commitment it takes to put together that higher level of content about the problems – so hardly anything ever made it into the blog.  It is time for a change.

So going forward, I’m still not going to be ‘link blogging’ anymore.  I’m quite happy being a consumer of: http://www.alvinashcraft.com/, http://blog.cwa.me.uk/, http://www.dirkstrauss.com/ and http://regulargeek.com/ (to name a few).  If you want to know some of the links that I do find interesting in the morning, you can follow me on twitter (@haleyjason), I do often tweet links as I find them worthy of a good read.

I am now going to focus on blogging about the stuff I care about and am interested in … and that will mostly not be article/whitepaper worthy stuff

Monitor the Status of an Azure WebJob

Last year I started using Azure WebJobs to run some background processing for a website. At the time, I was not using the WebJob SDK at all, I was just writing console apps that blocked and stayed in a loop … and most of the time everything worked great.

Every now and then, I would notice the webjob restarting or being in some status other than “running” or “stopped”. Most of the time the problem ended up being my code - things like data scenarios that weren’t accounted for in the code or maybe config settings that I didn’t update before deploying … you know dumb stuff that you catch pretty quick. Solving the problems that occurred right after I deployed new jobs was pretty easy. However, it wasn’t as easy to know if a problem occurred at some other point in time so I could address the problem proactively.


If a WebJob goes down and no one is looking at the portal to notice … did it really go down?

The answer of course is: yes! But if the webjob is down, how could you have it tell you it is down? Seems like its sort of a chicken and egg problem. The first solution that came to mind was a dead man switch that pinged a heartbeat every so many seconds or minutes to let me know if it is a live. Then of course I would need to write the monitoring code to check for the updates and notify me when they are outside of the expected time limits.  All doable … though I didn’t really want to write a monitoring system.

Turns out, Microsoft has already solved this for you with web tests.

Web tests

My initial exposure to web tests were the ping tests that you can setup to call your site from different data centers in order to test for a specific status code and/or text in the result. Very useful stuff for monitoring websites. A good overview of web tests can be found here: Monitor availability and responsiveness of any web site.

Problem: The webjob doesn’t expose a URL so how can I setup a web test?

Solution: the WebJobs API and the multi-step web test.

On the WebJobs API github page, towards the bottom - you will find the apis for continuous jobs. The api that I needed was just a simple GET call.

As long as I am logged into the azure portal, I can access the WebJobs api off of the Kudu url: http://<yourwebsite>.scm.azurewebsites.net/api/continuousjobs/<jobname> to get the webjob’s current information -> included the status.

Next problem: How do you get the web test to be logged into the azure portal in order to call the WebJobs api?

This is where the multi-step web test comes in. One of the cool things about the Kudu api is that is also supports basic authentication – which means the call to the api and authentication can all be done in a single http call. In order to get the Authorization header set, you need to create a Web Performance Test.

Here are the steps to create a Web Performance Test using Visual Studio

1. Open Visual Studio, File -> New Project

2. In the search box, type performance

3. Select the Web Performance and Load Test project template


4. Give the project whatever name you want (you don’t really need to project – just the .webtest file)

5. Click OK

Once the project loads, you should have the WebTest1.webtest active in the editor

Create the request

6. In the editor, right click on the WebTest1 node and select Add Request

7. In the properties window, set the following properties (make sure you replace the values in the url with your values):

Expected HTTP Status Code = 200
Url = https://<yourwebsite>.scm.azurewebsites.net/api/continuousjobs/<jobname>


Add the basic authentication header

8. In the editor, right click on the request node and select Add Header

9. In the properties window, change the Name to Authorization

The username and password you use for basic authentication with Kudu is the same username/password you use for FTP or deployment. This information can be found and reset in the Web App –> Settings -> Deployment credentials blade in the portal.


The value of the Authorization header is “Basic <base64encodedString>”. The things to note here are: the prefix “Basic” with a space after it and the base64 encoded string of <username>:<password>.

Header value Example:

For the username: simplewebjob1 and a password of “password1234$”. Base64 encode the string “simplewebjob1:password1234$” to get c2ltcGxld2Viam9iMTpwYXNzd29yZDEyMzQk

Now add the prefix to get the final header value of “Basic c2ltcGxld2Viam9iMTpwYXNzd29yZDEyMzQk”

10. Set the Value to your basic authentication header value (you can encode your username password here on my utilities page).

Add the validation to look for “status”:”Running”

11. In the editor, right click on the request node and select Add Validation Rule…

This will open the Add Validation Rule dialog

12. Select the Find Text rule

13. Set the Find Text property to the following:


14. Click OK.

The editor should look something like the following when you are done:


Now save and run the test in Visual Studio to verify it works.

This WebTest1.webtest file can be used to create a multi-step web test in the Azure portal.  If you need help on doing that, a great walkthrough how to setup the web test in the portal is about half way down this article: Monitor availability and responsiveness of any web site.