Azure WebJobs, It’s whats new in Azure!
The long awaited webjobs is now in preview for Windows Azure! How many times have you deployed a website, then after a couple months requirements change and they want you to run a daily or continuous job that processes files or re-size images or works a queue, now with web jobs in Windows Azure it is easy. In this post I will explain how you can deploy this Azure Web Job as part of your Azure web site (PaaS), You just deploy and you are done. There is no need to zip up files and go to the management console. A one shot deal!
Some common applications for such web jobs include:
- Image Processing
- Log file cleanup
- Queue Processing
- Long running tasks that you normally perform in the background.
Azure WebJobs can be run in one of two ways. The first being continuously and the second being via a trigger (schedule or an event). Running a webjob continuously is much like having a worker role, but when you run a webjob, it will run on the same VM as your website. So if that is important to you, then you would probably want to use a webjob. If it is not, a worker role should work just fine.
Adding an Azure WebJob
There are a couple ways to add a Windows Azure WebJob, one is how most of the examples show you on the Azure website (http://www.windowsazure.com/en-us/documentation/articles/web-sites-create-web-jobs/) or you can deploy it as part of your Azure website.
This seems to be the easiest to do promotes code reuse. Plus each time you publish your website you do not need to go and re-upload all your webjobs. The example I show below has an .exe and all the configuration files in a directory called webjob that I want to run continuously. The secret to getting this to work is putting everything in the correct directories. The convention is as follows
Note: Your job type will be “Continuous” or “Triggered”
So in my case
Once this is deployed you will notice that the webjob automatically shows up in the Azure management studio.
For my example above there is one more step that needs to be performed which is adding the connection string to the Windows Azure Storage account “AzureJobsRuntime” to you can see the log files. This can be done under the configure tab