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
WebJobs is a feature of Azure App Service 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. This sample uses a Triggered (scheduled) WebJob to output the system time once every 15 minutes.
15
+
WebJobs is a feature of Azure App Service that enables you to run a program or script in the same instance as a web app. All app service plans support WebJobs at no additional cost. This sample uses a scheduled (Triggered) WebJob to output the system time once every minute.
16
16
17
17
## Prerequisites
18
18
19
19
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?ref=microsoft.com&utm_source=microsoft.com&utm_medium=docs&utm_campaign=visualstudio).
20
-
- An existing App Service app on Linux. In this quickstart, [a Python app](quickstart-python.md) is used.
21
-
-**[Always on](configure-common.md?tabs=portal)** must enabled on your app.
22
-
- App setting `WEBSITE_SKIP_RUNNING_KUDUAGENT` set to `FALSE`.
20
+
- An existing App Service Python app on Linux. In this quickstart, a [Python app](quickstart-python) is used.
21
+
-**[Always on](configure-common.md?tabs=portal#configure-general-settings)** must be enabled on your app.
22
+
-Ensure the App setting `WEBSITE_SKIP_RUNNING_KUDUAGENT`is set to `false`.
23
23
24
24
## Download the sample WebJob
25
25
@@ -28,9 +28,12 @@ dotnet
28
28
:::zone-end
29
29
30
30
:::zone target="docs" pivot="python"
31
-
[Download the sample project](https://github.com/Azure-Samples/App-Service-Python-WebJobs-QuickStart/archive/refs/heads/main.zip).
32
31
33
-
The sample Python WebJob is in `webjob.py`. It outputs the current time to the console as shown below:
32
+
You can [download a pre-built sample project](https://github.com/Azure-Samples/App-Service-Python-WebJobs-QuickStart/archive/refs/heads/main.zip) to get started quickly.
33
+
34
+
The sample includes two files that will run the WebJob: `webjob.py` and `run.sh`.
35
+
36
+
The Python script, `webjob.py`, that outputs the current time to the console as shown below:
34
37
35
38
```Python
36
39
import datetime
@@ -46,7 +49,8 @@ The file, `run.sh`, calls WebJob.py as shown below:
46
49
/opt/python/3/bin/python3.13 webjob.py
47
50
```
48
51
49
-
The file, `run.sh` is included to show the capability of WebJobs. You can also omit the file and only include `webjob.py` in the .zip file.
52
+
> [!NOTE]
53
+
> `run.sh` invokes the Python script. It's included in the .zip to show the flexibility of WebJobs. Depending on your project needs, you can also omit `run.sh` from your WebJob.
|**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 "_". |
81
85
|**File Upload**| Python-webjob.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 section. |
82
-
|**Type**| Scheduled |Continous, Triggered, or Scheduled. |
83
-
|**Triggers**| Scheduled |For the scheduling to work reliably, `Always On` should be enabled (available in Basic, Standard, and Premium tiers).|
86
+
|**Type**| Scheduled |Specifies when the WebJob runs. Choose `Scheduled` to run based on a CRON expression. |
87
+
|**Triggers**| Scheduled |Ensure Always On is enabled for the schedule to work reliably. This setting is available in Basic, Standard, and Premium tiers.|
84
88
|**CRON Expression**| 0 0/1 * * * * | For this quickstart, we use a schedule that runs every minute. See [CRON expressions](webjobs-create.md?tabs=windowscode#ncrontab-expressions) to learn more about the syntax. |
85
89
86
90
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**.
87
91
88
-
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.
92
+
1. The scheduled WebJob is run at the schedule defined by the CRON expression. To run it manually at any time, right-click the WebJob in the list and select the **Run** button, then confirm your selection.
89
93
90
94
:::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.":::
When you deploy a scheduled WebJob to Azure App Service, the platform checks for a CRON schedule and runs the script at the specified time intervals. If `run.sh` or `run.py` is present, it's used as the entry point. Otherwise, the platform will use the first `.py` file it detects in the archive, which can lead to unpredictable results.
101
+
102
+
103
+
## Review the WebJob logs
104
+
105
+
106
+
## Clean up
107
+
108
+
To remove the WebJob, select the WebJob in the portal and select `Delete`.
109
+
94
110
## <aname="NextSteps"></a> Next steps
95
111
96
112
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