Ever since we’ve had (web) applications we’ve had a need for tasks that are executed on a regular basis or at specific points in time. A common way to do this is through some sort of scheduler, like the Windows Task Scheduler or from some custom (Windows) service. In a web based or cloud scenario you can now also use the Windows Azure Scheduler to do this. Scheduler basically offers two options to kick off a task in an application: with an HTTP(S) call or using a Windows Azure Storage Queue. In this post I will focus on the former.
Right now Scheduler is in preview, so you’ll have to request it before you can use it. To do so, go to and click try it now and follow the process until Scheduler is enabled for you.
Once you can use Scheduler you can create new jobs. Just click NEW at the bottom left of the page and select Scheduler, as shown below.
When you click CUSTOM CREATE a wizard pops up to guide you through the process of creating a job. First you have to select or create a Job Collection, as shown below.
A Job Collection is tied to a specific region, so if you select a region where you don’t have a collection yet, it will default to creating a new one. Next, you need to specify the job details, as shown below.
You can select three Action Types: HTTP, HTTPS, and Storage Queue. Here I’ve selected HTTP, which gives you four method types: GET, POST, PUT and DELETE. Although you can use these differently, these correspond to Read, Insert, Update, and Delete in most REST based APIs. Above I’m creating a HTTP GET job. You just have to specify the URL that gets called when the job fires.
The last thing you have to do is specify the schedule. You have a choice for a one time job that fires immediately or at a specified time, or a recurring job as shown below.
When you create a recurring job you also have the choice of starting it immediately or at a specific time. You also have to specify when the schedule ends. Above I’ve set that to the year 9999, which is effectively indefinitely.
When you’ve created your first job, you can go to the Scheduler section in the Management Portal. It will show you all collections you’ve created, in my case just the one, as shown below.
When you click the collection you go to the dashboard, which shows you what’s been happening, as you can see below.
For more details you can go to HISTORY, where you can select the job you want information about, and filter all the by status. You see a list of all jobs that have been executed and their result. As shown below for one of my jobs.
When you select one of the jobs you can click on VIEW HISTORY DETAILS to get details about the exact response you received. For a successful job that looks something like the figure below, just the full HTTP response from the server.
For a failed job it’s not much different, as shown below. Notice that the body contains more information, so if you have control over the endpoint the scheduler is calling, you can add a comprehensive error message that enables you to debug the endpoint.
For now, editing jobs is not possible. You can only create jobs, delete jobs, are enable/disable all jobs. You can do the latter by clicking UPDATE JOBS at the bottom of the dashboard of a Job Collection, as shown below.
There are two plans for the scheduler. The preview defaults to Standard, which allows for a maximum of 50 jobs and an interval up to a minute. The free plan allows for a maximum of 5 jobs, which can run at most every hour. You can change your plan under SCALE, as shown below.
So you’ve created a job, now what? If it’s a get job, basically it’s going to call the URL you specified at the interval you specified. At your endpoint you can run a page or a Web API get request method, or something similar. The request sent to the endpoint looks like this:
GET HTTP/1.1 Connection: Keep-Alive Host: schedulerdemoenpoint.cloudapp.net x-ms-execution-tag: c912f04ea3d225912c8e9dcc82090fe3 x-ms-client-request-id: 6009d929-587c-4051-b588-0ad2f9b14f16 x-ms-scheduler-expected-execution-time: 2014-01-01T17:16:13 x-ms-scheduler-jobid: DemoGetJob x-ms-scheduler-jobcollectionid: DemoCollection x-ms-scheduler-execution-region: North Europe
As you can see Azure Scheduler adds several headers with information about the job. Part of it is static information about the job, but the execution tag, request id, and execution time are unique for each request.
Notice that the region is North Europe, despite the fact that I defined the Job Collection in West Europe. This is not a fluke on my part. As you can see in the different responses to the POST, PUT, and DELETE job the region is different sometimes. In fact, if you go into the management portal you will see a different region sometimes. I assume this has something to do with high-availability between data centers, and I also assume that the two data centers closest to one another are used for this.
POST HTTP/1.1 Connection: Keep-Alive Content-Length: 17 Content-Type: text/plain Host: schedulerdemoenpoint.cloudapp.net x-ms-execution-tag: 728d411206720536d592f1f2cde52e8a x-ms-client-request-id: 134dea00-e323-4832-9aae-e847ed3884ba x-ms-scheduler-expected-execution-time: 2014-01-01T19:21:04 x-ms-scheduler-jobid: DemoPostJob x-ms-scheduler-jobcollectionid: DemoCollection x-ms-scheduler-execution-region: West Europe
Demo POST content
PUT HTTP/1.1 Connection: Keep-Alive Content-Length: 16 Content-Type: text/plain Host: schedulerdemoenpoint.cloudapp.net x-ms-execution-tag: d62c789c2574f287af9216226d7e48a2 x-ms-client-request-id: 7003fe19-e127-4004-a9e1-1973f066155c x-ms-scheduler-expected-execution-time: 2014-01-01T19:19:54 x-ms-scheduler-jobid: DemoPutJob x-ms-scheduler-jobcollectionid: DemoCollection x-ms-scheduler-execution-region: North Europe
Demo PUT Content
DELETE HTTP/1.1 Connection: Keep-Alive Content-Length: 0 Host: schedulerdemoenpoint.cloudapp.net x-ms-execution-tag: 5eb0e16e3eb9e880ee6edf969c376014 x-ms-client-request-id: 5d2b18e5-4e45-48f4-bf64-620393195c56 x-ms-scheduler-expected-execution-time: 2014-01-01T17:20:48 x-ms-scheduler-jobid: DemoDeleteJob x-ms-scheduler-jobcollectionid: DemoCollection x-ms-scheduler-execution-region: West Europe
Continue with .