How To Create Web Job in Azure Web app


Azure Web Job is the most useful feature in Azure WebApp service. It is greatly helpful when you want to run the scripts or programs as background processes in app services, API, app and mobile app.

You can also upload and run an executable file such as cmd, bat, exe, ps 1, sh, php, py etc. These programs all run as Web Jobs on a schedule (cron) or continuously.

The purpose of the web job is to simplify the code and also to perform the common tasks, such as image processing, file maintenance, and sending mails. The web job SDK has a great in-built feature for working with Azure storage and Service bus. It is very helpful for many scenarios like scheduling tasks and handling errors etc.

By using Visual Studio, you can create, deploy and manage Web Jobs. It’s seamless with integrating tooling in Visual Studio. It’s very easy to create Web Jobs from templates, publish, manage (run,stop,monitor and debug) them.

Let's see an example of how to create a Web job and host it on Azure:

  • Open Visual Studio.
  • Create New project -> File -> New - project

    Web Job in Azure
  • Now select Template -> Cloud - Azure Web Job And give appropriate name and location path where you want to create project in your local directory.
  • Click on Ok button.

    Web Job in Azure
  • You will see the solution structure like this

    Web Job in Azure 
  • You can use this web job for various purpose as I mentioned earlier like to send mail notification etc.
  • Now we will see how to upload this web job on to azure.
  • First you need to build and run your solution for creating the exe or dll files.
  • You can upload zip of your solution into the web job.
  • Go to solution explorer right click on your project then click on open folder in file explorer.

    Web Job in Azure
  • Now create a zip which you will upload on web job.

    Web Job in Azure 
  • Now upload this zip file in web job.
  • Open Azure portal - open your web app.

    Web Job in Azure 
  • Type Web job in Search Box.

    Web Job in Azure 
  • And then click on Web Jobs so new blade will open as shown in the below image.

    Web Job in Azure 
  • Then Click on ADD ‘+’ Sign.

    Web Job in Azure 
  • New Window will open.

    Web Job in Azure 
  • Enter the name
  • Upload the file which you already zipped and Select type
  • Select Type – “Triggered or Continuous “according to your required.
  • Let's say we select Triggered because we want to run our web job as scheduled.
  • So next Select Triggers as “Scheduled or manual “.
  • Let Say We Select Scheduled.
  • Give the CRON Expression.
  • Referred for better understanding of CRON Expression.
  • Let's say we give 0 */5 * * * * To the CRON Expression.
  • We want to trigger our web job once in every 5 minutes.
  • Click on Ok Button.

    Web Job in Azure 
  • You will see your job status like this.

    Web Job in Azure 


In this article, we learned how to Create Web Job in Azure Web apps. I hope you like it if you have any questions drop me a message.

Up Next
    Ebook Download
    View all
    View all