Many times, in our web projects, we require a process to run separately from the main thread of the website. We had a scenario once to host our ASP.NET website on Windows Azure and there are different ways to do this.
The following file types are supported -
- .cmd, .bat, .exe (using Windows cmd)
- .ps1 (using PowerShell)
- .sh (using Bash)
- .php (using PHP)
- .py (using Python)
- .js (using Node.js)
- .jar (using Java)
a- Write the code in global.asax startup method and run a timer. But that will run inside the main thread of website so it is not advisable to do that, as any sort of crash in either website or the timer thread will cause the pool to restart.
b- Write a Windows Service, this is a classic model if we have a Virtual machine in place, but if we have hosted our website as a Windows Azure Website, then this will not work.
c- If we host a Windows Azure website, which is a common scenario, Windows Azure provides an option to configure the WebJob host from the control panel where we can assign different properties like Triggering [continous, manual] and scheduling.
The Windows Azure WebJobs SDK is a framework that simplifies the task of adding background processing to Windows Azure Web Sites.
Aside from the main project, create a new C# Console application.
First, we need to install “Azure WebJobs SDK”, we can add it through NuGet module in our Visual Studio project.
To create a new WebJobs-enabled project, you can use the Console Application project template and enable WebJobs deployment as explained in the previous section. As an alternative, you can use the WebJobs new-project template:
- Use the WebJobs new-project template for an independent WebJob Create a project and configure it to deploy by itself as a WebJob, with no link to a web project. Use this option when you want to run a WebJob in a web app by itself, with no web application running in the web app. You might want to do this in order to be able to scale your WebJob resources independently of your web application resources.
- Use the WebJobs new-project template for a WebJob linked to a web project Create a project that is configured to deploy automatically as a WebJob when a web project in the same solution is deployed. Use this option when you want to run your WebJob in the same web app in which you run the related web application
Use the WebJobs new-project template for an independent WebJob
- Click File > New Project, and then in the New Project dialog box click Cloud > Azure WebJob (.NET Framework).

- Follow the directions shown earlier to make the Console Application project an independent WebJobs project.





Join the conversation! Your thoughts help the community grow.