You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Azure WebJobs allow you to run background tasks within your App Service app, without needing separate infrastructure. These tasks are discovered and managed by the Kudu engine, the built-in App Service deployment and runtime management service. Kudu handles WebJob execution, file system access, diagnostics, and log collection behind the scenes.
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
16
17
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
18
19
19
## Platform-specific notes
20
20
21
-
WebJobs support a variety of script and executable formats, depending on the App Service hosting environment. The types of files you can run—and 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, and additional file types are supported when they match the language runtime of your app or container.
21
+
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 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.
> WebJobs that are continuous, scheduled, or event-driven may 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 do not keep the app active.
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
27
> To ensure WebJobs run reliably, enable the Always on setting in the Configuration pane of your App Service.
28
28
> This setting is available only in the Basic, Standard, and Premium pricing tiers.
29
29
@@ -47,14 +47,15 @@ Inside the job folder, the Kudu engine looks for a file to execute. This file ca
47
47
48
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
49
50
-
The filename must be exactly `run.*` to be autodetected. Files like `start.sh` or `job.py` will be 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:
51
-
- A Python WebJob with multiple `.py` files (for example, `file1.py`, `file2.py`) will execute the first `.py` file it finds in the archive.
50
+
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:
51
+
52
+
- A Python WebJob with multiple `.py` files (for example, `file1.py`, `file2.py`) runs the first `.py` file it finds in the archive.
52
53
- A Node.js WebJob looks for the first `.js` file.
53
54
- A Bash-based WebJob looks for the first `.sh` script.
54
55
55
-
This fallback behavior can lead to unpredictable execution when multiple script files are present—especially in multi-file projects—so it's recommended to include a `run.*` file to define the entry point explicitly.
56
+
This fallback behavior can lead to unpredictable execution when multiple script files are present—especially in multi-file projects. We recommended that you include a `run.*` file to define the entry point explicitly.
56
57
57
-
On Linux-based WebJobs, `.sh` scripts must include a shebang (#!) and must be marked as executable.
58
+
On Linux-based WebJobs, `.sh` scripts must include a shebang (`#!`) and must be marked as executable.
58
59
59
60
## WebJob configuration with settings.job
60
61
@@ -64,12 +65,12 @@ You can customize WebJob behavior using an optional `settings.job` file (JSON fo
64
65
|----------|-------------|
65
66
|`schedule`| (string) A CRON expression used to schedule a triggered job. Example: `"0 */15 * * * *"`. Only applicable to triggered jobs. |
66
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. |
67
-
|`stopping_wait_time`| (number, seconds) Grace period (default 5s) given to the script before it's killed when the WebJob is stopped (for example, during site swaps or restarts). |
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). |
68
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. |
69
70
|`run_mode`| (string) Values: `continuous`, `scheduled`, `on_demand`. Overrides job type detection based on the folder. |
70
71
71
72
> [!NOTE]
72
-
> `stopping_wait_time` applies specifically to the running script's grace period, while `shutdownGraceTimeLimit` defines the overall process shutdown time-out. Consult the [Kudu documentation](https://github.com/projectkudu/kudu/wiki/WebJobs) for detailed behavior.
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.
73
74
74
75
### Example
75
76
```json
@@ -83,7 +84,7 @@ You can customize WebJob behavior using an optional `settings.job` file (JSON fo
83
84
84
85
## Logging and diagnostics
85
86
86
-
WebJob logs are handled by the Kudu engine and are 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:
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:
@@ -95,7 +96,7 @@ Triggered WebJobs include a full history of executions. Continuous WebJobs strea
95
96
## Troubleshooting tips
96
97
97
98
-**WebJob not starting:** Check for a missing or misnamed `run.*` file. Ensure it's in the correct job folder (`triggered` or `continuous`).
98
-
-**Permissions error (Linux):** Ensure the script has execute permissions (`chmod +x run.sh`) and includes a valid shebang (e.g., `#!/bin/bash`).
99
+
-**Permissions error (Linux):** Ensure the script has execute permissions (`chmod +x run.sh`) and includes a valid shebang (for example, `#!/bin/bash`).
99
100
-**Job not stopping gracefully:** Use `settings.job` to define `stopping_wait_time` and potentially `shutdownGraceTimeLimit`.
100
101
-**Scheduled job not running:** Verify the CRON expression in `settings.job` is correct and the App Service Plan has "Always On" enabled if needed.
101
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.
0 commit comments