Skip to content

Commit ca5711d

Browse files
committed
updates
1 parent 8334ae8 commit ca5711d

File tree

2 files changed

+98
-9
lines changed

2 files changed

+98
-9
lines changed

articles/app-service/quickstart-webjobs.md

Lines changed: 96 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,110 @@ The file, `run.sh`, calls WebJob.py as shown below:
4747
/opt/python/3/bin/python3.13 webjob.py
4848
```
4949

50-
> [!NOTE]
51-
> The platform uses `run.py` or `run.sh` as the entry point for the Python WebJobs. If neither is present, it defaults to the first `.py` file it finds in the archive, which can lead to unpredictable results—especially when multiple `.py` files are included.
50+
## Create a scheduled WebJob
51+
52+
1. In the [Azure portal](https://portal.azure.com), go to the **App Service** page of your App Service app.
53+
54+
1. From the left pane, select **WebJobs**, then select **Add**.
55+
56+
:::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).":::
57+
58+
1. Fill in the **Add WebJob** settings as specified in the table, then select **Create Webjob**. For **File Upload**, be sure to select the .zip file you downloaded earlier in the [Download the sample WebJob](#download-the-sample-webjob) section.
59+
60+
:::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.":::
61+
62+
| Setting | value | Description  |
63+
| ------------ | ----------------- | ------------ |
64+
| **Name** | webjob | The WebJob name. Must start with a letter or a number and must not contain special characters other than "-" and "_". |
65+
| **File Upload** | App-Service-Python-WebJobs-Quickstart-Main.zip | The *.zip* file that contains your executable or script file. The supported file types are listed in the [supported file types](webjobs-create.md?tabs=windowscode#acceptablefiles) section. |
66+
| **Type** | Triggered | Specifies when the WebJob runs: Continuous or Triggered. |
67+
| **Triggers** | Scheduled | Scheduled or Manual. Ensure [Always on](configure-common.md?tabs=portal#configure-general-settings) is enabled for the schedule to work reliably.|
68+
| **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. |
5269

70+
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**.
71+
72+
1. The scheduled WebJob is run at the schedule defined by the CRON expression.
73+
74+
:::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.":::
5375
:::zone-end
5476

5577
:::zone target="docs" pivot="node"
56-
node
78+
79+
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. The sample includes two files: `webjob.js` and `run.sh`.
80+
81+
The Javascript, `webjob.js`, outputs the current time to the console as shown below:
82+
83+
```Javascript
84+
// Import the 'Date' object from JavaScript
85+
const currentTime = new Date();
86+
87+
// Format the time as a string
88+
const formattedTime = currentTime.toLocaleTimeString();
89+
90+
// Output the formatted time to the console
91+
console.log(`Current system time is: ${formattedTime}`);
92+
```
93+
94+
The file, `run.sh`, calls webjob.js as shown below:
95+
96+
```Bash
97+
#!/bin/bash
98+
99+
node webjob.js
100+
```
101+
## Create a scheduled WebJob
102+
103+
1. In the [Azure portal](https://portal.azure.com), go to the **App Service** page of your App Service app.
104+
105+
1. From the left pane, select **WebJobs**, then select **Add**.
106+
107+
:::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).":::
108+
109+
1. Fill in the **Add WebJob** settings as specified in the table, then select **Create Webjob**. For **File Upload**, be sure to select the .zip file you downloaded earlier in the [Download the sample WebJob](#download-the-sample-webjob) section.
110+
111+
:::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.":::
112+
113+
| Setting | value | Description  |
114+
| ------------ | ----------------- | ------------ |
115+
| **Name** | webjob | The WebJob name. Must start with a letter or a number and must not contain special characters other than "-" and "_". |
116+
| **File Upload** | App-Service-Node-WebJobs-Quickstart-Main.zip | The *.zip* file that contains your executable or script file. The supported file types are listed in the [supported file types](webjobs-create.md?tabs=windowscode#acceptablefiles) section. |
117+
| **Type** | Triggered | Specifies when the WebJob runs: Continuous or Triggered. |
118+
| **Triggers** | Scheduled | Scheduled or Manual. Ensure [Always on](configure-common.md?tabs=portal#configure-general-settings) is enabled for the schedule to work reliably.|
119+
| **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. |
120+
121+
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**.
122+
123+
1. The scheduled WebJob is run at the schedule defined by the CRON expression.
124+
125+
:::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.":::
57126
:::zone-end
58127

59128
:::zone target="docs" pivot="java"
60129
java
61130
:::zone-end
62131

63132
:::zone target="docs" pivot="php"
64-
php
65-
:::zone-end
133+
You can [download a pre-built sample project](https://github.com/Azure-Samples/App-Service-PHP-WebJobs-QuickStart/archive/refs/heads/main.zip) to get started quickly. The sample includes two files: `webjob.php` and `run.sh`.
134+
135+
The PHP script, `webjob.php`, outputs the current time to the console as shown below:
136+
137+
```PHP
138+
<?php
139+
// Get the current time
140+
$current_time = date("Y-m-d H:i:s");
141+
142+
// Display the current time
143+
echo "The current time is: " . $current_time;
144+
?>
145+
```
66146

147+
The file, `run.sh`, calls webjob.php as shown below:
148+
149+
```Bash
150+
#!/bin/bash
151+
152+
php -f webjob.php
153+
```
67154

68155
## Create a scheduled WebJob
69156

@@ -80,7 +167,7 @@ php
80167
| Setting | value | Description  |
81168
| ------------ | ----------------- | ------------ |
82169
| **Name** | webjob | The WebJob name. Must start with a letter or a number and must not contain special characters other than "-" and "_". |
83-
| **File Upload** | App-Service-Python-WebJobs-Quickstart-Main.zip | The *.zip* file that contains your executable or script file. The supported file types are listed in the [supported file types](webjobs-create.md?tabs=windowscode#acceptablefiles) section. |
170+
| **File Upload** | App-Service-PHP-WebJobs-Quickstart-Main.zip | The *.zip* file that contains your executable or script file. The supported file types are listed in the [supported file types](webjobs-create.md?tabs=windowscode#acceptablefiles) section. |
84171
| **Type** | Triggered | Specifies when the WebJob runs: Continuous or Triggered. |
85172
| **Triggers** | Scheduled | Scheduled or Manual. Ensure [Always on](configure-common.md?tabs=portal#configure-general-settings) is enabled for the schedule to work reliably.|
86173
| **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. |
@@ -91,6 +178,8 @@ php
91178

92179
:::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.":::
93180

181+
:::zone-end
182+
94183
[!INCLUDE [webjobs-cron-timezone-note](../../includes/webjobs-cron-timezone-note.md)]
95184

96185
## Review the WebJob logs
@@ -114,4 +203,4 @@ To remove the WebJob, select the WebJob in the portal and select `Delete`.
114203

115204
## <a name="NextSteps"></a> Next steps
116205

117-
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).
206+
How to run

articles/app-service/webjobs-create.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Run Background Tasks with WebJobs
2+
title: How-to 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
@@ -12,7 +12,7 @@ ms.reviewer: glenga;suwatch;pbatum;naren.soni;
1212
#Customer intent: As a web developer, I want to leverage background tasks to keep my application running smoothly.
1313
---
1414

15-
# Run background tasks with WebJobs in Azure App Service
15+
# Run background tasks with WebJobs
1616

1717
This article explains how to deploy WebJobs by using the [Azure portal](https://portal.azure.com) to upload an executable or script. 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.
1818

0 commit comments

Comments
 (0)