Understanding WebJobs

Another feature of Azure App Services is WebJobs. With WebJobs, you can run scripts or programs as background processes on Azure App Service web apps, APIs, and mobile apps, without any additional costs. Some scenarios that would be suitable for WebJobs are long-running tasks, such as for sending emails and file maintenance, such as aggregating or cleaning up log files, queue processing, RSS aggregation and image processing, and other CPU-intensive work. You can upload and run executable files such as the following: 

  • .ps1 (using PowerShell)
  • .cmd, .bat, and .exe (using Windows CMD)
  • .sh (using Bash)
  • .py (using Python)
  • .php (using PHP)
  • .js (using Node.js)
  • .jar (using Java)

There are two different types of WebJobs:

  • Continuous: This starts immediately after creating the WebJob. The work inside the WebJob is run inside an endless loop to keep the job from ending. By default, continuous WebJobs run on all the instances that the web app runs; however, you can configure the WebJob so that it runs on a single instance as well. Continuous WebJobs support remote debugging.
  • Triggered: This starts on a schedule, but when triggered manually, it runs on a single instance that is selected by Azure for load balancing. A triggered WebJob doesn't support remote debugging.
At the time of writing, WebJobs aren't yet supported for App Service on Linux.
Web Apps can time out after 20 minutes of inactivity. The timer can only be reset when a request is made to the Web App. The Web App's configuration can be viewed by making requests to the advanced tools site or in the Azure portal. If your app runs continuous or scheduled (timer triggered) WebJobs, enable Always On to ensure that the WebJobs run reliably. The Always On feature is only available in the Basic, Standard, and Premium plans.

In the next demonstration, we are going to create a background task using WebJobs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset