WebJobs

WebJobs are background services that can be run by triggering from outside sources, on-demand, or continuous. They run under the same Web App and are managed by Azure Service Fabric. These are a good choice when we have to run an application as a background process for a longer run. One Web App can have a multiple number of WebJobs, and they can all share the same memory, CPU usage, and storage. As WebJobs and Web Apps share the same resources, any of the high-intensity jobs can affect the performance of other WebJobs or Web Apps, and vice versa. WebJobs can listen for events from Queue, blobs, and WebHooks, and can be triggered manually or scheduled to run at a certain time.

WebJobs are highly recommended for scenarios where heavy plumbing is needed. For example, let's consider a correspondence system that generates documents for different vendors as selected on the form, and each vendor gets the document containing information specific to that vendor. In this scenario, if the vendor list is big, the user may get a request timeout, as a document will be generated and e-mailed for each vendor. To design this scenario, we can use Azure Storage Queue, which keeps the messages needed to be processed. This queue will trigger our Web Job to process that message by generating a document, and send that as an attachment to the corresponding vendor:

There are many other scenarios, like image processing, file maintenance, and other long running tasks that take a substantial amount of time and may experience the server response timeout scenarios.

WebJobs can be triggered in three different ways, as follows:

WebJobs Type Description
On-Demand This is generally triggered from the Azure portal, or if listening to some storage queues, tables, Service bus, and blobs using Azure, the WebJobs SDK can trigger automatically when any new message is created.
Scheduled WebJobs can be scheduled and triggered at a specified time.
Continuous Runs continuously, but explicit code needs to be written to keep it alive.

WebJobs can be deployed by placing the files in a particular filesystem, and can be any of the following types:

  • .exe (executable file)
  • .bat (batch file)
  • .sh (Bash file)
  • .php (PHP file)
  • .py (Python file)
  • .js (JavaScript file)
..................Content has been hidden....................

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