Skip to content

Commit eeafcec

Browse files
committed
indents
1 parent 4ca872e commit eeafcec

File tree

1 file changed

+85
-84
lines changed

1 file changed

+85
-84
lines changed

articles/app-service/quickstart-webjobs.md

Lines changed: 85 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ WebJobs is a feature of Azure App Service that enables you to run a program
2323
- **[Always on](configure-common.md?tabs=portal#configure-general-settings)** must be enabled on your app.
2424
- Ensure the App setting `WEBSITE_SKIP_RUNNING_KUDUAGENT` is set to `false`.
2525

26-
## Create your sample WebJob
26+
## Create your sample locally
2727

2828
1. In this step, you create a basic .NET WebJob project and navigate to the project root.
2929

@@ -50,37 +50,37 @@ class Program
5050

5151
1. From the *webjob* directory, run the webjob to confirm the current time is output to the console:
5252

53-
```bash
54-
dotnet run
55-
```
56-
57-
You should see output similar to the following:
58-
59-
```bash
60-
Current time with is: 07:53:07 PM -05:00
61-
```
53+
```bash
54+
dotnet run
55+
```
56+
57+
You should see output similar to the following:
58+
59+
```bash
60+
Current time with is: 07:53:07 PM -05:00
61+
```
6262

6363
1. Once you've confirmed the app works, build it and navigate to the parent directory:
6464
65-
```bash
66-
dotnet build --self-contained
67-
68-
cd ..
69-
```
65+
```bash
66+
dotnet build --self-contained
67+
68+
cd ..
69+
```
7070
7171
1. Next we to create `run.sh` with the following code:
7272
73-
```text
74-
#!/bin/bash
75-
76-
dotnet webjob/bin/Debug/net9.0/webjob.dll
77-
```
73+
```text
74+
#!/bin/bash
75+
76+
dotnet webjob/bin/Debug/net9.0/webjob.dll
77+
```
7878
7979
1. Now package all the files into a .zip as shown below:
8080
81-
```bash
82-
zip webjob.zip run.sh webjob/bin/Debug/net9.0/*
83-
```
81+
```bash
82+
zip webjob.zip run.sh webjob/bin/Debug/net9.0/*
83+
```
8484
8585
## Create a scheduled WebJob in Azure
8686
@@ -127,19 +127,19 @@ You can [download a pre-built sample project](https://github.com/Azure-Samples/A
127127

128128
The Python script, `webjob.py`, outputs the current time to the console as shown below:
129129

130-
```Python
131-
import datetime
132-
133-
current_datetime = datetime.datetime.now()
134-
print(current_datetime) # Output: 2025-03-27 10:27:21.240752
135-
```
130+
```Python
131+
import datetime
132+
133+
current_datetime = datetime.datetime.now()
134+
print(current_datetime) # Output: 2025-03-27 10:27:21.240752
135+
```
136136

137137
The file, `run.sh`, calls WebJob.py as shown below:
138138

139-
```Bash
140-
#!/bin/bash
141-
/opt/python/3/bin/python3.13 webjob.py
142-
```
139+
```Bash
140+
#!/bin/bash
141+
/opt/python/3/bin/python3.13 webjob.py
142+
```
143143

144144
## Create a scheduled WebJob
145145

@@ -185,24 +185,25 @@ You can [download a pre-built sample project](https://github.com/Azure-Samples/A
185185
186186
The JavaScript, `webjob.js`, outputs the current time to the console as shown below:
187187
188-
```JavaScript
189-
// Import the 'Date' object from JavaScript
190-
const currentTime = new Date();
191-
192-
// Format the time as a string
193-
const formattedTime = currentTime.toLocaleTimeString();
194-
195-
// Output the formatted time to the console
196-
console.log(`Current system time is: ${formattedTime}`);
197-
```
188+
```JavaScript
189+
// Import the 'Date' object from JavaScript
190+
const currentTime = new Date();
191+
192+
// Format the time as a string
193+
const formattedTime = currentTime.toLocaleTimeString();
194+
195+
// Output the formatted time to the console
196+
console.log(`Current system time is: ${formattedTime}`);
197+
```
198198
199199
The file, `run.sh`, calls webjob.js as shown below:
200200
201-
```Bash
202-
#!/bin/bash
201+
```Bash
202+
#!/bin/bash
203+
204+
node webjob.js
205+
```
203206
204-
node webjob.js
205-
```
206207
## Create a scheduled WebJob
207208
208209
1. In the [Azure portal](https://portal.azure.com), go to the **App Service** page of your App Service app.
@@ -250,43 +251,43 @@ WebJobs is a feature of Azure App Service that enables you to run a program
250251

251252
Digging into the code, our Java project located at `project/src/main/java/webjob/HelloWorld.java` is relatively simple. It just outputs a message & the current time to the console.
252253

253-
```Java
254-
import java.time.LocalDateTime;
255-
256-
public class HelloWorld {
257-
258-
public static void main(String[] args) {
259-
260-
System.out.println("------------------------------------------------------------");
261-
System.out.println("Hello World from WebJob: " + LocalDateTime.now());
262-
System.out.println("------------------------------------------------------------");
254+
```Java
255+
import java.time.LocalDateTime;
256+
257+
public class HelloWorld {
258+
259+
public static void main(String[] args) {
260+
261+
System.out.println("------------------------------------------------------------");
262+
System.out.println("Hello World from WebJob: " + LocalDateTime.now());
263+
System.out.println("------------------------------------------------------------");
264+
}
263265
}
264-
}
265-
```
266+
```
266267
267268
### Build the Java WebJob
268269
269270
The run.sh script located at the root of our git repo, just runs a jar with the name that we’ve set in our maven configuration. This script will run when our WebJob is triggered, and it is the job of this script to kick off our Java executable (jar).
270271
271-
```bash
272-
java -jar webjob-artifact-1.0.0.jar
273-
```
272+
```bash
273+
java -jar webjob-artifact-1.0.0.jar
274+
```
274275
275276
Now we need to compile our Java project to produce the executable jar. There are multiple ways to do this, but for this example, we’ll use Maven. Run the following commands from the `project/` directory:
276277
277-
```bash
278-
mvn install
279-
mvn package
280-
```
278+
```bash
279+
mvn install
280+
mvn package
281+
```
282+
281283
After successfully building our app with `mvn package`, our jar file will be located at `project/target/webjob-artifact-1.0.0.jar`.
282284
283285
Now we have everything we need to assemble our zip file. Again, there are multiple ways to do this, but for this demo we’ll use the zip CLI utility to create our zip file called `webjob.zip`. First move your jar file to the root of the git repo with ` project/target/webjob-artifact-1.0.0.jar .` Then run the zip command to package our application as a zip file.
284286
285-
```bash
286-
287-
zip webjob.zip run.sh webjob-artifact-1.0.0.jar
287+
```bash
288+
zip webjob.zip run.sh webjob-artifact-1.0.0.jar
289+
```
288290
289-
```
290291
## Create a scheduled WebJob on Azure
291292
292293
1. In the [Azure portal](https://portal.azure.com), go to the **App Service** page of your App Service app.
@@ -332,23 +333,23 @@ You can [download a pre-built sample project](https://github.com/Azure-Samples/A
332333
333334
The PHP script, `webjob.php`, outputs the current time to the console as shown below:
334335
335-
```PHP
336-
<?php
337-
// Get the current time
338-
$current_time = date("Y-m-d H:i:s");
339-
340-
// Display the current time
341-
echo "The current time is: " . $current_time;
342-
?>
343-
```
336+
```PHP
337+
<?php
338+
// Get the current time
339+
$current_time = date("Y-m-d H:i:s");
340+
341+
// Display the current time
342+
echo "The current time is: " . $current_time;
343+
?>
344+
```
344345
345346
The file, `run.sh`, calls webjob.php as shown below:
346347
347-
```Bash
348-
#!/bin/bash
349-
350-
php -f webjob.php
351-
```
348+
```Bash
349+
#!/bin/bash
350+
351+
php -f webjob.php
352+
```
352353
353354
## Create a scheduled WebJob
354355

0 commit comments

Comments
 (0)