Intro to Azure Webjobs

Azure Webjobs is a topic that I have been planning to write for a long time, even before I took “Azure Webjobs and Some Advanced Scenario” session on Northern University Bangladesh(NUB) but never actually got time to write it down here on blog.  I guess today is the day when finally I will write stuffs on Azure Webjobs. This is the first part of Azure Webjobs series.

Almost all the enterprise application that I have worked with so far has one thing in common i.e. they all need to do some processing. This processing might required to execute in the background process or it might required  to run on scheduled intervals. For say, one of my web app requirement could be squeezing the image size while another web app requirement could be deleting the log files at specific time interval. As you can see the processing differs based on the business logic.  But that is not the point I want you to focus. Instead I would like to shed on the fact that all the web app has a common requirement and that is they need to perform some operation.  The common and easiest solution I could come up with such scenario is to build a simple command line app and then schedule it on windows scheduler. This would definitely works but I don’t want my client to run a server just for this simple purpose!  This is where Azure Webjobs come in to action.

So, What is Azure Webjobs?

In simple words, this is just a scheduler! But it runs as PaaS that means you don’t have to sweat the underlying infrastructure any more, you just call it and handover your task, azure will handle the rest for you. If you ask me what could be the selling tagline for this feature.  I would say “This is damn easy to implement and it comes with so many features and extensions that worth it to implement in any enterprise grade web apps.” It was codenamed SimpleBatch.

AzureWebjobs_basicArchitecture_01

Following is a list of task for which Azure Webjobs is the perfect candidate :

  • Image processing or other CPU-intensive work.
  • Queue processing.
  • RSS aggregation.
  • File maintenance, such as aggregating or cleaning up log files.
  • Other long-running tasks that you want to run in a background thread, such as sending emails.

But why do I use Azure Webjobs?

If you are like me, probably you won’t start using it unless you find real value in it. Let me tell you awesomeness of azure webjobs and there by help you decide if you really wants to check this out.

  • Its Free : Why buy a cow if you can get milk for free? Thats the point. Azure Webjobs comes in no cost. Plus using Azure Webjobs means you don’t have to take the headache to manage the underlying VM.
  • Automatic Queue triggered : This is something I like most about Azure Webjobs. It automatically triggered each time some new stuffs appears.  Following is a snapshot that shows how easily we can configure queue trigger system.
    QueueProcessing_01
  • Resilient to errors : The word resilient mean something that spring back into its original shape after bending.  While executing azure webjobs if a particular messages (its content) causes a function to fail then instead of deleting the queue message its picked up again and tries five times to perform the task, if it still can’t process the task then the message moved to poison queue.
    Ressilent
  • Work in parallel & Auto Scale out : It can pick and process maximum 16 message from a queue at a time ! Plus it scales out with your web app automatically.  Obviously you may not like this default behavior, me neither.
  • Unlimited in number :  Inside an web app you can fire up as much webjobs you want. But bear in mind even though webjobs does not cost you money but it uses your web apps resource. So, its good practice to keep the number limited.
  • Auto Deserialize : I already told you the awesomeness of azure webjobs i.e. automatic queue triggered feature. Now, here is another one. It can sense the response and does auto deserialization 🙂
  • Easy tracking from Portal : Portal experience for webjobs is superb. You can easily create and check the status of your webjobs. In fact if you want you can check the full stack trace and download it for further use.

Now that you are impressed, you might be wondering what sorts of expertise you need to have.

To be honest, You really don’t have to learn anything new! Azure webjobs support a large number of executable and scripts. If you can write code on any of the following you will be good to go with webjobs.

  • .exe – .NET assemblies compiled with the WebJobs SDK
  • .cmd, .bat, .exe (using windows cmd)
  • .sh (using bash)
  • .php (using php)
  • .py (using python)
  • .js (using node)
  • .ps1 (using powershell)
  • .jar (using java)
  • .fsx (using the F# fsi.exe interactive compiler)
  • project.json (using Dnx)

Wrapping Up:

We often run into situation when we want to take something simple and do it n times. When such situation arises i.e. you need to do cronjob/batch processing, you should consider implementing WebJobs as it makes developing, running and scaling easier. In the upcoming tutorial I will cover Webjobs in details.

Reference :

Advertisements

2 thoughts on “Intro to Azure Webjobs

  1. Pingback: Azure Webjobs deployment | LearnWithShahriar

  2. Pingback: Azure Webjob ebook is on the way ! | LearnWithShahriar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s