Starting Azure Platform as a Service (PaaS) Development 101 Series: Lesson 1 of n – Web Jobs


There is a lot of content available to develop for Azure, if you are looking for baby steps this series of lessons is defiantly not for you. However, if you are developer, regardless of background or platform and looking quickly to get your hands dirty, then you are at the right place. I will not be setting up a fixed or target number of lessons, I will share ideas along the way and keep adding more. This does not mean I don’t have an agenda, on the contrary! I started by asking myself about developer tasks during the life cycle of building a PaaS solution on Azure.

As I mentioned earlier, this a special series that focuses on a point, a task, a recipe. So don’t be surprised if we wont be building fancy samples, I am here to help you get on your feet with PaaS development on Azure.

What’s up for today?

I’ve been doing Azure PaaS development for a while now, and I can tell you that the best place to start learning the robes are Web Jobs. Let me quiz you quickly here: What would you do if you want to run background tasks, executable files, or even scripts on Azure? I bet you would say: let’s spin a new VM and put all that stuff there. Or at least that’s what we used to say before Web Jobs came to life. So in a nutshell, you can schedule and configure on demand executable applications and scripts to run on Azure without spinning a new VM Winking smile 

Let’s get cracking

Below is a simple command line application that will print a time stamp. We will create a Web Job and configure it to run this application every one minute. Yeah I know a bit cheesy, but hey if you can come up with more meaningful examples, fire up the comments section below Hot smile

1 using System; 2 3 namespace PaaS101.Lesson1 4 { 5 class Program 6 { 7 static void Main(string[] args) 8 { 9 Console.WriteLine(DateTime.Now); 10 } 11 } 12 }

Launch the Azure portal and head to Web Sites. Yep that’s right, Web Jobs sit inside Azure Websites and yes you can have multiple web jobs in the same Azure Website. Let’s create a new Website. I will use the same website through all the lessons. I called it paas101 and it will sit on http://paas101.azurewebsites.net.

image

Once created, click on paas101, select WEBJOBS tab, and create a new job.

image

Now you will have to compress your executable and their dependencies in one zip file. Since we decided to run it every minute then select “Run on a schedule” and choose your schedule region. Mine is “West Europe”.

image

Moving on to the next step, select “Recurring Job” for recurrence and set it for one minute. Looks like you have to specify and ending time. I just set it to 11:30PM today my time.

image

Once its done, you will notice that the status is set to “Enabled”. Let’s see how was the execution of our Web Job going. One of the columns is called “LOGS”. Navigate to the URL.

image

This is the logs URL for our Web Job: https://paas101.scm.azurewebsites.net/azurejobs/#/jobs/triggered/PrintTimeEveryOneMinute. Once you land on the logs page you will notice the previous runs below marked with a status:

image

Clicking on the web job will open the Web Job run details. As you can see from the screenshot below, the web job did print the time Smile

image

I hope you enjoyed the quick 101. Let me know if you have any questions or comments. Until next lesson Smile

Comments (3)

  1. abosos84 says:

    Awsome, when are you planning to release more lessons?

  2. Anonymous says:

    Please fill out the survey on WebJobs here: microsoft.qualtrics.com/SE

    Thanks!!

Skip to main content