Skip to content

Commit 9c3bbdc

Browse files
committed
Refresh article
1 parent 0e8b733 commit 9c3bbdc

File tree

1 file changed

+78
-47
lines changed

1 file changed

+78
-47
lines changed
Lines changed: 78 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
title: Run background tasks with WebJobs
2+
title: Run Background Tasks with WebJobs
33
description: Learn how to use WebJobs to run background tasks in Azure App Service. Choose from various script formats and run them with CRON expressions.
44

55
ms.assetid: af01771e-54eb-4aea-af5f-f883ff39572b
6-
ms.topic: conceptual
7-
ms.date: 3/01/2024
6+
ms.topic: concept-article
7+
ms.date: 4/17/2025
88
author: msangapu-msft
99
ms.author: msangapu
1010
ms.reviewer: cephalin;suwatch;pbatum;naren.soni;
@@ -17,47 +17,78 @@ adobe-target-content: ./webjobs-create-ieux
1717

1818
# Run background tasks with WebJobs in Azure App Service
1919

20-
Deploy WebJobs by using the [Azure portal](https://portal.azure.com) to upload an executable or script. You can run background tasks in the Azure App Service.
20+
This article explains how to deploy WebJobs by using the [Azure portal](https://portal.azure.com) to upload an executable or script. You can run background tasks in the Azure App Service.
2121

22-
If instead of the Azure App Service, you're using Visual Studio to develop and deploy WebJobs, see [Deploy WebJobs using Visual Studio](webjobs-dotnet-deploy-vs.md).
22+
If instead of the Azure App Service, you're using Visual Studio to develop and deploy WebJobs, see [Develop and deploy WebJobs using Visual Studio](webjobs-dotnet-deploy-vs.md).
2323

2424
> [!NOTE]
25-
> WebJobs for **Windows container**, **Linux code**, and **Linux container** is in preview. WebJobs for Windows code is generally available and not in preview.
25+
> WebJobs for *Windows container*, *Linux code*, and *Linux container* is in preview. WebJobs for Windows code is generally available and not in preview.
2626
2727
## Overview
2828

29-
WebJobs is a feature of [Azure App Service](index.yml) that enables you to run a program or script in the same instance as a web app. All app service plans support WebJobs. There's no extra cost to use WebJobs.
29+
WebJobs is a feature of [Azure App Service](index.yml) that allows you to run a program or script in the same instance as a web app. All app service plans support WebJobs. There's no extra cost to use WebJobs.
3030

31-
You can use the Azure WebJobs SDK with WebJobs to simplify many programming tasks. For more information, see [What is the WebJobs SDK](https://github.com/Azure/azure-webjobs-sdk/wiki).
31+
You can use the [Azure WebJobs SDK](https://github.com/Azure/azure-webjobs-sdk/wiki) with WebJobs to simplify many programming tasks.
3232

33-
Azure Functions provides another way to run programs and scripts. For a comparison between WebJobs and Functions, see [Choose between Flow, Logic Apps, Functions, and WebJobs](../azure-functions/functions-compare-logic-apps-ms-flow-webjobs.md).
33+
Azure Functions provides another way to run programs and scripts. For a comparison between WebJobs and Functions, see [Choose the right integration and automation services in Azure](../azure-functions/functions-compare-logic-apps-ms-flow-webjobs.md).
3434

3535
## WebJob types
3636

3737
### <a name="acceptablefiles"></a>Supported file types for scripts or programs
3838

3939
### [Windows code](#tab/windowscode)
40-
The following file types are supported:<br>
41-
**.cmd**, **.bat**, **.exe** (using Windows cmd)<br>**.ps1** (using PowerShell)<br>**.sh** (using Bash)<br>**.js** (using Node.js)<br>**.jar** (using Java)<br><br>The necessary runtimes to run these file types are already installed on the web app instance.
40+
41+
The following file types are supported:
42+
43+
- Using Windows cmd: *.cmd*, *.bat*, *.exe*
44+
45+
- Using PowerShell: *.ps1*
46+
47+
- Using Bash: *.sh*
48+
49+
- Using Node.js: *.js*
50+
51+
- Using Java: *.jar*
52+
53+
The necessary runtimes to run these file types are already installed on the web app instance.
54+
4255
### [Windows container](#tab/windowscontainer)
56+
4357
> [!NOTE]
4458
> WebJobs for Windows container is in preview.
4559
>
4660
47-
The following file types are supported:<br>
48-
**.cmd**, **.bat**, **.exe** (using Windows cmd)<br><br>In addition to these file types, WebJobs written in the language runtime of the Windows container app.<br>Example: .jar and .war scripts if the container is a Java app.
61+
The following file types are supported:
62+
63+
- Using Windows cmd: *.cmd*, *.bat*, *.exe*
64+
65+
In addition to these file types, WebJobs written in the language runtime of the Windows container app are supported.
66+
67+
- Example: *.jar* and *.war* scripts are supported if the container is a Java app.
68+
4969
### [Linux code](#tab/linuxcode)
70+
5071
> [!NOTE]
5172
> WebJobs for Linux code is in preview.
5273
>
5374
54-
**.sh** scripts are supported.<br><br>In addition to shell scripts, WebJobs written in the language of the selected runtime are also supported.<br>Example: Python (.py) scripts if the main site is a Python code app.
75+
*.sh* scripts are supported.
76+
77+
In addition to shell scripts, WebJobs written in the language of the selected runtime are also supported.
78+
79+
- Example: Python (*.py*) scripts are supported if the main site is a Python app.
80+
5581
### [Linux container](#tab/linuxcontainer)
82+
5683
> [!NOTE]
57-
> WebJobs for Linux container is in preview.
84+
> WebJobs for Linux container is in preview.
5885
>
5986
60-
**.sh** scripts are supported. <br><br>In addition to shell scripts, WebJobs written in the language runtime of the Linux container app are also supported. <br>Example: Node (.js) scripts if the site is a Node.js app.
87+
*.sh* scripts are supported.
88+
89+
In addition to shell scripts, WebJobs written in the language runtime of the Linux container app are also supported.
90+
91+
- Example: Node (*.js*) scripts are supported if the site is a Node.js app.
6192

6293
---
6394

@@ -88,17 +119,17 @@ when making changes in one don't forget the other two.
88119
89120
1. In the [Azure portal](https://portal.azure.com), go to the **App Service** page of your App Service web app, API app, or mobile app.
90121

91-
1. From the left pane, select **WebJobs**, then select **Add**.
122+
1. Under **Settings** in the left pane, select **WebJobs**, then select **Add**.
92123

93-
:::image type="content" source="media/webjobs-create/add-webjob.png" alt-text="Screenshot that shows how to add a WebJob in an App Service app in the portal.":::
124+
:::image type="content" source="media/webjobs-create/add-webjob.png" alt-text="Screenshot that shows how to add a WebJob in an App Service app in the portal." lightbox="media/webjobs-create/add-webjob.png":::
94125

95126
1. Fill in the **Add WebJob** settings as specified in the table, then select **Create Webjob**.
96127

97128
:::image type="content" source="media/webjobs-create/configure-new-continuous-webjob.png" alt-text="Screenshot that shows how to configure a multi-instance continuous WebJob for an App Service app.":::
98129

99130
| Setting | Sample value | Description  |
100131
| ------------ | ----------------- | ------------ |
101-
| **Name** | myContinuousWebJob | A name that is unique within an App Service app. Must start with a letter or a number and must not contain special characters other than "-" and "_". |
132+
| **Name** | myContinuousWebJob | A name that's unique within an App Service app. Must start with a letter or a number and must not contain special characters other than `"-"` and `"_"`. |
102133
| **File Upload** | ConsoleApp.zip | A *.zip* file that contains your executable or script file and any supporting files needed to run the program or script. The supported executable or script file types are listed in the [Supported file types](#acceptablefiles) section. |
103134
| **Type** | Continuous | The [WebJob types](#webjob-types) are described earlier in this article. |
104135
| **Scale** | Multi Instance | Available only for Continuous WebJobs. Determines whether the program or script runs on all instances or one instance. The option to run on multiple instances doesn't apply to the Free or Shared [pricing tiers](https://azure.microsoft.com/pricing/details/app-service/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio). |
@@ -107,7 +138,7 @@ when making changes in one don't forget the other two.
107138

108139
1. To stop or restart a continuous WebJob, right-click the WebJob in the list and select the **Stop** or **Run** button, then confirm your selection.
109140

110-
:::image type="content" source="media/webjobs-create/continuous-webjob-stop.png" alt-text="Screenshot that shows how to stop a continuous WebJob in the Azure portal.":::
141+
:::image type="content" source="media/webjobs-create/continuous-webjob-stop.png" alt-text="Screenshot that shows how to stop a continuous WebJob in the Azure portal." lightbox="media/webjobs-create/continuous-webjob-stop.png":::
111142

112143
## <a name="CreateOnDemand"></a> Create a manually triggered WebJob
113144

@@ -118,17 +149,17 @@ when making changes in one don't forget the other two.
118149

119150
1. In the [Azure portal](https://portal.azure.com), go to the **App Service** page of your App Service web app, API app, or mobile app.
120151

121-
1. From the left pane, select **WebJobs**, then select **Add**.
152+
1. Under **Settings** in the left pane, select **WebJobs**, then select **Add**.
122153

123-
:::image type="content" source="media/webjobs-create/add-webjob.png" alt-text="Screenshot that shows how to add a WebJob in an App Service app in the portal (manually triggered WebJob).":::
154+
:::image type="content" source="media/webjobs-create/add-webjob.png" alt-text="Screenshot that shows how to add a WebJob in an App Service app in the portal (manually triggered WebJob)." lightbox="media/webjobs-create/add-webjob.png":::
124155

125156
1. Fill in the **Add WebJob** settings as specified in the table, then select **Create Webjob**.
126157

127158
:::image type="content" source="media/webjobs-create/configure-new-triggered-webjob.png" alt-text="Screenshot that shows how to configure a manually triggered WebJob for an App Service app.":::
128159

129160
| Setting | Sample value | Description  |
130161
| ------------ | ----------------- | ------------ |
131-
| **Name** | myTriggeredWebJob | A name that is unique within an App Service app. Must start with a letter or a number and must not contain special characters other than "-" and "_".|
162+
| **Name** | myTriggeredWebJob | A name that's unique within an App Service app. Must start with a letter or a number and must not contain special characters other than `"-"` and `"_"`.|
132163
| **File Upload** | ConsoleApp1.zip | A *.zip* file that contains your executable or script file and any supporting files needed to run the program or script. The supported executable or script file types are listed in the [Supported file types](#acceptablefiles) section. |
133164
| **Type** | Triggered | The [WebJob types](#webjob-types) are described previously in this article. |
134165
| **Triggers** | Manual | |
@@ -137,7 +168,7 @@ when making changes in one don't forget the other two.
137168

138169
1. To run a manually triggered WebJob, right-click the WebJob in the list and select the **Run** button, then confirm your selection.
139170

140-
:::image type="content" source="media/webjobs-create/triggered-webjob-run.png" alt-text="Screenshot that shows how to run a manually triggered WebJob in the Azure portal.":::
171+
:::image type="content" source="media/webjobs-create/triggered-webjob-run.png" alt-text="Screenshot that shows how to run a manually triggered WebJob in the Azure portal." lightbox="media/webjobs-create/triggered-webjob-run.png":::
141172

142173
## <a name="CreateScheduledCRON"></a> Create a scheduled WebJob
143174

@@ -150,31 +181,31 @@ when making changes in one don't forget the other two.
150181

151182
1. In the [Azure portal](https://portal.azure.com), go to the **App Service** page of your App Service web app, API app, or mobile app.
152183

153-
1. From the left pane, select **WebJobs**, then select **Add**.
184+
1. Under **Settings** in the left pane, select **WebJobs**, then select **Add**.
154185

155-
:::image type="content" source="media/webjobs-create/add-webjob.png" alt-text="Screenshot that shows how to add a WebJob in an App Service app in the portal (scheduled WebJob).":::
186+
:::image type="content" source="media/webjobs-create/add-webjob.png" alt-text="Screenshot that shows how to add a WebJob in an App Service app in the portal (scheduled WebJob)." lightbox="media/webjobs-create/add-webjob.png":::
156187

157188
1. Fill in the **Add WebJob** settings as specified in the table, then select **Create Webjob**.
158189

159190
:::image type="content" source="media/webjobs-create/configure-new-scheduled-webjob.png" alt-text="Screenshot that shows how to configure a scheduled WebJob in an App Service app.":::
160191

161192
| Setting | Sample value | Description  |
162193
| ------------ | ----------------- | ------------ |
163-
| **Name** | myScheduledWebJob | A name that is unique within an App Service app. Must start with a letter or a number and must not contain special characters other than "-" and "_". |
194+
| **Name** | myScheduledWebJob | A name that's unique within an App Service app. Must start with a letter or a number and must not contain special characters other than `"-"` and `"_"`. |
164195
| **File Upload** | ConsoleApp.zip | A *.zip* file that contains your executable or script file and any supporting files needed to run the program or script. The supported executable or script file types are listed in the [Supported file types](#acceptablefiles) section. |
165196
| **Type** | Triggered | The [WebJob types](#webjob-types) are described earlier in this article. |
166197
| **Triggers** | Scheduled | For the scheduling to work reliably, enable the Always On feature. Always On is available only in the Basic, Standard, and Premium pricing tiers.|
167198
| **CRON Expression** | 0 0/20 * * * * | [CRON expressions](#ncrontab-expressions) are described in the following section. |
168199

169200
1. The new WebJob appears on the **WebJobs** page. If you see a message that says the WebJob was added, but you don't see it, select **Refresh**.
170201

171-
1. The scheduled WebJob is run at the schedule defined by the CRON expression. To run it manually at anytime, right-click the WebJob in the list and select the **Run** button, then confirm your selection.
202+
1. The scheduled WebJob is run according to the schedule defined by the CRON expression. To run it manually at anytime, right-click the WebJob in the list and select the **Run** button, then confirm your selection.
172203

173-
:::image type="content" source="media/webjobs-create/scheduled-webjob-run.png" alt-text="Screenshot that shows how to run a manually scheduled WebJob in the Azure portal.":::
204+
:::image type="content" source="media/webjobs-create/scheduled-webjob-run.png" alt-text="Screenshot that shows how to run a manually scheduled WebJob in the Azure portal." lightbox="media/webjobs-create/scheduled-webjob-run.png":::
174205

175206
## NCRONTAB expressions
176207

177-
You can enter a [NCRONTAB expression](../azure-functions/functions-bindings-timer.md#ncrontab-expressions) in the portal or include a `settings.job` file at the root of your WebJob *.zip* file, as in the following example:
208+
An NCRONTAB expression is similar to a CRON expression, but includes an additional sixth field at the beginning for time precision in seconds. You can enter an [NCRONTAB expression](../azure-functions/functions-bindings-timer.md#ncrontab-expressions) in the portal or include a `settings.job` file at the root of your WebJob *.zip* file, as in the following example:
178209

179210
```json
180211
{
@@ -188,33 +219,33 @@ To learn more, see [Scheduling a triggered WebJob](webjobs-dotnet-deploy-vs.md#s
188219

189220
## Manage WebJobs
190221

191-
You can manage the running state individual WebJobs running in your site in the [Azure portal](https://portal.azure.com). Go to **Settings** > **WebJobs**, choose the WebJob, and you can start and stop the WebJob. You can also view and modify the password of the webhook that runs the WebJob.
222+
You can manage the run state of individual WebJobs running in your site by using the [Azure portal](https://portal.azure.com). Go to **Settings** > **WebJobs**, choose the WebJob, and you can start and stop the WebJob. You can also view and modify the password of the webhook that runs the WebJob.
192223

193-
You can also [add an application setting](configure-common.md#configure-app-settings) named `WEBJOBS_STOPPED` with a value of `1` to stop all WebJobs running on your site. You can use this method to prevent conflicting WebJobs from running both in staging and production slots. You can similarly use a value of `1` for the `WEBJOBS_DISABLE_SCHEDULE` setting to disable triggered WebJobs in the site or a staging slot. For slots, remember to enable the **Deployment slot setting** option so that the setting itself doesn't get swapped.
224+
You can also [configure an app setting](configure-common.md#configure-app-settings) named `WEBJOBS_STOPPED` with a value of `1` to stop all WebJobs running on your site. You can use this method to prevent conflicting WebJobs from running both in staging and production slots. You can similarly use a value of `1` for the `WEBJOBS_DISABLE_SCHEDULE` setting to disable triggered WebJobs in the site or a staging slot. For slots, remember to enable the **Deployment slot setting** option so that the setting itself doesn't get swapped.
194225

195226
## <a name="ViewJobHistory"></a> View the job history
196227

197228
1. For the WebJob you want to see, select **Logs**.
198229

199-
:::image type="content" source="media/webjobs-create/open-logs.png" alt-text="Screenshot that shows how to access logs for a WebJob.":::
200-
201-
2. In the **WebJob Details** page, select a time to see details for one run.
202-
203-
:::image type="content" source="media/webjobs-create/webjob-details-page.png" alt-text="Screenshot that shows how to choose a WebJob run to see its detailed logs.":::
230+
:::image type="content" source="media/webjobs-create/open-logs.png" alt-text="Screenshot that shows how to access logs for a WebJob." lightbox="media/webjobs-create/open-logs.png":::
231+
232+
1. In the **WebJob Details** page, select a time to see details for one run.
233+
234+
:::image type="content" source="media/webjobs-create/webjob-details-page.png" alt-text="Screenshot that shows how to choose a WebJob run to see its detailed logs." lightbox="media/webjobs-create/webjob-details-page.png":::
204235

205-
3. In the **WebJob Run Details** page, you can select **download** to get a text file of the logs, or select the **WebJobs** breadcrumb link at the top of the page to see logs for a different WebJob.
236+
1. In the **WebJob Run Details** page, you can select **download** to get a text file of the logs, or select the **WebJobs** breadcrumb link at the top of the page to see logs for a different WebJob.
206237

207-
## WebJob statuses
238+
## WebJob status
208239

209-
The following is a list of common WebJob statuses:
240+
The following is a list of common WebJob states:
210241

211-
- **Initializing** The app has started and the WebJob is going through its initialization process.
212-
- **Starting** The WebJob is starting up.
213-
- **Running** The WebJob is running.
214-
- **PendingRestart** A continuous WebJob exits in less than two minutes since it started for any reason, and App Service waits 60 seconds before restarting the WebJob. If the continuous WebJob exits after the two-minute mark, App Service doesn't wait the 60 seconds and restarts the WebJob immediately.
215-
- **Stopped** The WebJob was stopped (usually from the Azure portal) and is currently not running and won't run until you start it again manually, even for a continuous or scheduled WebJob.
216-
- **Aborted** This can occur for many of reasons, such as when a long-running WebJob reaches the timeout marker.
242+
- **Initializing**: The app has started and the WebJob is going through its initialization process.
243+
- **Starting**: The WebJob is starting up.
244+
- **Running**: The WebJob is running.
245+
- **PendingRestart**: A continuous WebJob exits in less than two minutes since it started for any reason, and App Service waits 60 seconds before restarting the WebJob. If the continuous WebJob exits after the two-minute mark, App Service doesn't wait the 60 seconds and restarts the WebJob immediately.
246+
- **Stopped**: The WebJob was stopped (usually from the Azure portal) and is currently not running and won't run until you start it again manually, even for a continuous or scheduled WebJob.
247+
- **Aborted**: This can occur for many of reasons, such as when a long-running WebJob reaches the time-out marker.
217248

218-
## <a name="NextSteps"></a> Next steps
249+
## <a name="NextSteps"></a> Next step
219250

220251
The Azure WebJobs SDK can be used with WebJobs to simplify many programming tasks. For more information, see [What is the WebJobs SDK](https://github.com/Azure/azure-webjobs-sdk/wiki).

0 commit comments

Comments
 (0)