
close
close
In this post, I will explain how you can use WebJobs to execute tasks on Azure App Service.
You might require some sort of task to run in Azure, for example, when I upload an image via a Web App, a background task will pick up that image, do something to it, and then email me a link to download the results.
This sort of task was historically done by a WebJob, a task that could execute in the abstracted virtual machine environment of Azure App Services. A WebJob, in short, is some script or executable that can be run continuously, manually started, or triggered on a scheduled basis.
advertisment
WebJobs run in Azure App Service plans. There are two considerations, especially for larger applications:
Azure Functions are similar to WebJobs because they allow you to perform some task in the background. Functions are triggered by a schedule or event; in other words, an instance of the Function is instantiated by Azure in response to something happening to perform a task. When that task is completed, the instance disappears. There is no server, so there is no big incremental cost; instead you pay for each second of Function run time. On the plus side, smaller tasks should reduce your Azure costs and Functions can scale beyond the limitations of your App Service plans. On the downside, there is a potential for a huge bill if your Functions go wild. Azure App Service plans have a fixed/predictable per-instance (virtual machine) cost.
Functions currently support C#, JavaScript, and F# with another of other languages and scripting environments in an experimental stage. WebJobs however, support a number of scripting languages and .CMD, .BAT, and compiled executables:
So while Functions are hot right now, WebJobs still have an important role to play, especially when one is migrating existing applications to Azure.
This process is quite simple. Create a new Web App, which is confusingly called an App Service in the Azure Portal. Open the App Service and open Settings > WebJobs.
Click + Add and a Add WebJob blade will appear. Enter the following information:
advertisment
If you selected Continuous you have two options for Scale:
If you select Triggered, then you can choose between:
Note that you must ensure that Always On is enabled in the Application Settings of the Web App before adding a continuous or scheduled WebJob.
A New Azure App Service WebJob that Will Run an Executable Every Day at 21:00 [Image Credit: Aidan Finn]
A New Azure App Service WebJob [Image Credit: Aidan Finn]
advertisment
More in Microsoft Azure
Build 2022: Microsoft's Intelligent Data Platform Combines Data and Analytics
May 25, 2022 | Rabia Noureen
Microsoft Revises Restrictive Cloud Licensing Policies to Avoid EU Antitrust Probe
May 19, 2022 | Rabia Noureen
Microsoft's Azure AD Conditional Access Service Can Now Require Reauthentication
May 13, 2022 | Rabia Noureen
Microsoft Addresses Cross-Tenant Database Vulnerability in Azure PostgreSQL
Apr 29, 2022 | Rabia Noureen
Microsoft Simplifies IT Monitoring with New Azure Managed Grafana Service
Apr 19, 2022 | Rabia Noureen
Most popular on petri