Skip to content

Commit d41bbf7

Browse files
Freshness.
1 parent 2174edf commit d41bbf7

1 file changed

Lines changed: 32 additions & 29 deletions

File tree

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
---
22
title: How WebJobs run in Azure App Service
3-
description: Understand how WebJobs are discovered, triggered, and managed by the Kudu engine in Azure App Service.
3+
description: Learn how the Kudu engine discovers, triggers, and manages WebJobs in Azure App Service. Azure WebJobs can run background tasks in your app.
44
ms.topic: conceptual
55
ms.service: azure-app-service
66
author: msangapu-msft
77
ms.author: msangapu
8-
ms.date: 05/01/2025
8+
ms.date: 12/02/2025
99
ms.update-cycle: 180-days
1010
ms.collection: ce-skilling-ai-copilot
11+
#customer intent: As an app developer, I need to understand how WebJobs work in Azure App Service to discover and manage background tasks.
1112
---
1213

1314
# How WebJobs run in Azure App Service
1415

15-
Azure WebJobs allow you to run background tasks within your App Service app, without needing separate infrastructure. The Kudu engine discovers and manages these tasks. The Kudu engine is the built-in App Service deployment and runtime management service. Kudu handles WebJob execution, file system access, diagnostics, and log collection behind the scenes.
16+
Azure WebJobs allow you to run background tasks in your App Service app, without needing separate infrastructure. The Kudu engine discovers and manages these tasks. The Kudu engine is the built-in App Service deployment and runtime management service. Kudu handles WebJob execution, file system access, diagnostics, and log collection behind the scenes.
1617

17-
This article explains how WebJobs are discovered, how the runtime decides what to execute, and how you can configure behavior using the optional `settings.job` file.
18+
This article explains how WebJobs are discovered, how the runtime decides what to run, and how you can configure behavior using the optional `settings.job` file.
1819

1920
## Platform-specific notes
2021

21-
WebJobs support various script and executable formats, depending on the App Service hosting environment. The types of files you can runand the runtimes available—vary slightly based on whether you're using Windows code, Linux code, or custom containers. In general, built-in runtimes are available for common scripting languages. Other file types are supported when they match the language runtime of your app or container.
22+
WebJobs support various script and executable formats, depending on the App Service hosting environment. The types of files you can run and the runtimes available vary based on whether you're using Windows code, Linux code, or custom containers. In general, built-in runtimes are available for common scripting languages. Other file types are supported when they match the language runtime of your app or container.
2223

2324
[!INCLUDE [webjob-types](./includes/webjobs-create/webjob-types.md)]
2425

25-
>[!IMPORTANT]
26-
> WebJobs that are continuous, scheduled, or event-driven might stop running if the web app hosting them becomes idle. Web apps can time out after 20 minutes of inactivity, and only direct requests to the app reset this idle timer. Actions like viewing the portal or accessing the Kudu tools don't keep the app active.
27-
> To ensure WebJobs run reliably, enable the Always on setting in the Configuration pane of your App Service.
26+
> [!IMPORTANT]
27+
> WebJobs that are continuous, scheduled, or event-driven might stop running if the web app that hosts them becomes idle. Web apps can time out after 20 minutes of inactivity, and only direct requests to the app reset this idle timer. Actions like viewing the portal or accessing the Kudu tools don't keep the app active.
28+
>
29+
> To ensure WebJobs run reliably, enable the **Always on** setting in the **Configuration** pane of your App Service.
30+
>
2831
> This setting is available only in the Basic, Standard, and Premium pricing tiers.
2932
3033
## Job discovery and folder structure
@@ -36,43 +39,42 @@ WebJobs are stored in the `site/wwwroot/App_Data/jobs/` folder of your App Servi
3639

3740
Each job has its own subfolder under the corresponding type, named after the WebJob. For example:
3841

39-
```
40-
App_Data/jobs/triggered/myjob/
41-
App_Data/jobs/continuous/myjob/
42-
```
42+
`App_Data/jobs/triggered/myjob/`
43+
`App_Data/jobs/continuous/myjob/`
4344

44-
Inside the job folder, the Kudu engine looks for a file to execute. This file can be a script or executable.
45+
Inside the job folder, the Kudu engine looks for a file to run. This file can be a script or executable.
4546

4647
## Entry point detection
4748

48-
The WebJobs runtime uses a file named `run.*` (such as `run.py`, `run.sh`, or `run.js`) as the explicit entry point for a job. This file tells the platform which script or binary to execute first, ensuring consistent and predictable behavior across environments.
49+
The WebJobs runtime uses a file named `run.*`, such as `run.py`, `run.sh`, or `run.js`, as the explicit entry point for a job. This file tells the platform which script or binary to execute first, which ensures consistent and predictable behavior across environments.
4950

5051
The filename must be exactly `run.*` to be autodetected. Files like `start.sh` or `job.py` are ignored unless manually triggered. If no `run.*` file is found, the platform attempts to detect a fallback entry point by selecting the first supported file based on the language platform of the WebJob. For example:
5152

5253
- A Python WebJob with multiple `.py` files (for example, `file1.py`, `file2.py`) runs the first `.py` file it finds in the archive.
5354
- A Node.js WebJob looks for the first `.js` file.
5455
- A Bash-based WebJob looks for the first `.sh` script.
5556

56-
This fallback behavior can lead to unpredictable execution when multiple script files are presentespecially in multi-file projects. We recommended that you include a `run.*` file to define the entry point explicitly.
57+
If multiple script files are present, especially in multi-file projects, this fallback behavior can lead to unpredictable execution. We recommended that you include a `run.*` file to define the entry point explicitly.
5758

5859
On Linux-based WebJobs, `.sh` scripts must include a shebang (`#!`) and must be marked as executable.
5960

6061
## WebJob configuration with settings.job
6162

62-
You can customize WebJob behavior using an optional `settings.job` file (JSON format) placed in the job's root folder. This file supports several properties:
63+
You can customize WebJob behavior using an optional `settings.job` file (JSON format) in the job's root folder. This file supports several properties:
6364

64-
| Property | Description |
65-
|----------|-------------|
66-
| `schedule` | (string) A CRON expression used to schedule a triggered job. Example: `"0 */15 * * * *"`. Only applicable to triggered jobs. |
67-
| `is_singleton` | (bool) Ensures only one instance of the job runs across all scaled-out instances. Default: `true` for continuous jobs, `false` for triggered/on-demand. |
68-
| `stopping_wait_time` | (number, seconds) Grace period (default 5 seconds) given to the script before it's killed when the WebJob is stopped (for example, during site swaps or restarts). |
69-
| `shutdownGraceTimeLimit` | (number, seconds) Max time (default 0s, meaning no limit) given for the entire WebJob process shutdown, including the `stopping_wait_time`, before it's forcefully terminated. |
70-
| `run_mode` | (string) Values: `continuous`, `scheduled`, `on_demand`. Overrides job type detection based on the folder. |
65+
| Property | Format | Description |
66+
|----------|------|-------|
67+
| `schedule` | string | A CRON expression used to schedule a triggered job. Example: `"0 */15 * * * *"`. Only applicable to triggered jobs. |
68+
| `is_singleton` | bool | Ensures only one instance of the job runs across all scaled-out instances. Default: `true` for continuous jobs, `false` for triggered/on-demand. |
69+
| `stopping_wait_time` | number, seconds | Grace period (default 5 seconds) given to the script before it stops when the WebJob stops, for example, during site swaps or restarts. |
70+
| `shutdownGraceTimeLimit` | number, seconds | Max time (default 0s, meaning no limit) given for the entire WebJob process shutdown, including the `stopping_wait_time`, before it's forcefully terminated. |
71+
| `run_mode` | string | Values: `continuous`, `scheduled`, `on_demand`. Overrides job type detection based on the folder. |
7172

7273
> [!NOTE]
73-
> `stopping_wait_time` applies specifically to the running script's grace period, while `shutdownGraceTimeLimit` defines the overall process shutdown timeout. Consult the [Kudu documentation](https://github.com/projectkudu/kudu/wiki/WebJobs) for detailed behavior.
74+
> `stopping_wait_time` applies specifically to the running script's grace period, while `shutdownGraceTimeLimit` defines the overall process shutdown timeout. For more information, see [Kudu documentation](https://github.com/projectkudu/kudu/wiki/WebJobs).
7475
7576
### Example
77+
7678
```json
7779
{
7880
"schedule": "0 0 * * * *", // Run once at the top of every hour
@@ -84,24 +86,25 @@ You can customize WebJob behavior using an optional `settings.job` file (JSON fo
8486

8587
## Logging and diagnostics
8688

87-
The Kudu engine handles WebJob logs. They're available under the `App_Data/jobs/<type>/<jobname>` folder. Additionally, logs can be viewed in the Azure portal or accessed via the SCM (Kudu) endpoint:
89+
The Kudu engine handles WebJob logs. They're available in the `App_Data/jobs/<type>/<jobname>` folder. Additionally, logs can be viewed in the Azure portal or accessed by using the SCM (Kudu) endpoint:
8890

89-
```
91+
```http
9092
https://<your-app>.scm.azurewebsites.net/api/triggeredwebjobs/<job>/history
9193
```
94+
9295
For more advanced monitoring and querying capabilities, consider integrating with [Application Insights](/azure/azure-monitor/app/app-insights-overview).
9396

9497
Triggered WebJobs include a full history of executions. Continuous WebJobs stream logs in real time.
9598

9699
## Troubleshooting tips
97100

98-
- **WebJob not starting:** Check for a missing or misnamed `run.*` file. Ensure it's in the correct job folder (`triggered` or `continuous`).
101+
- **WebJob not starting:** Check for a missing or misnamed `run.*` file. Ensure it's in the correct job folder: `triggered` or `continuous`.
99102
- **Permissions error (Linux):** Ensure the script has execute permissions (`chmod +x run.sh`) and includes a valid shebang (for example, `#!/bin/bash`).
100103
- **Job not stopping gracefully:** Use `settings.job` to define `stopping_wait_time` and potentially `shutdownGraceTimeLimit`.
101104
- **Scheduled job not running:** Verify the CRON expression in `settings.job` is correct and the App Service Plan has "Always On" enabled if needed.
102-
- **Check Kudu logs:** Examine the detailed execution logs and deployment logs available in the Kudu console (`https://<your-app>.scm.azurewebsites.net/`) under Tools > WebJobs and potentially Log stream.
105+
- **Check Kudu logs:** Examine the detailed execution logs and deployment logs available in the Kudu console (`https://<your-app>.scm.azurewebsites.net/`) under **Tools** > **WebJobs** and potentially Log stream.
103106

104-
## <a name="NextSteps"></a> Next steps
107+
## <a name="NextSteps"></a> Related content
105108

106109
- [WebJobs overview](overview-webjobs.md)
107110
- [Create a scheduled WebJob](quickstart-webjobs.md)

0 commit comments

Comments
 (0)