Skip to content

Commit b0ab84f

Browse files
committed
draft
1 parent 54a9011 commit b0ab84f

File tree

4 files changed

+264
-306
lines changed

4 files changed

+264
-306
lines changed

articles/app-service/includes/quickstart-java/quickstart-java-javase.md

Lines changed: 121 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -3,92 +3,67 @@ author: cephalin
33
ms.service: azure-app-service
44
ms.devlang: java
55
ms.topic: include
6-
ms.date: 04/23/2025
6+
ms.date: 06/10/2025
77
ms.author: cephalin
88
---
99

10-
In this quickstart, you use the [Maven Plugin for Azure App Service Web Apps](https://github.com/microsoft/azure-maven-plugins/blob/develop/azure-webapp-maven-plugin/README.md) to deploy a Java web application with an embedded server to [Azure App Service](/azure/app-service/). App Service provides a highly scalable, self-patching web app hosting service. Use the tabs to switch between Tomcat, JBoss, or embedded server (Java SE) instructions.
10+
[Azure App Service](/azure/app-service/) provides a highly scalable, self-patching web app hosting service. At the top of the page, choose how you want to deploy your app: **Java SE**, **Tomcat**, or **JBoss**, and then follow the corresponding instructions.
1111

12-
The quickstart deploys either a Spring Boot app, Quarkus app, or embedded Tomcat using the [azure-webapp-maven-plugin](https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App) plugin.
12+
In this quickstart, you use the [Maven Plugin for Azure App Service Web Apps](https://github.com/microsoft/azure-maven-plugins/blob/develop/azure-webapp-maven-plugin/README.md) to deploy a Java web application with an embedded Spring Boot, Quarkus, or Tomcat server to App Service. For more information, see [azure-webapp-maven-plugin](https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App).
1313

14-
### [Spring Boot](#tab/springboot)
15-
16-
:::image type="content" source="../../media/quickstart-java/springboot-hello-world-in-browser-azure-app-service.png" alt-text="Screenshot of Spring Boot Hello World web app running in Azure App Service in introduction.":::
17-
18-
### [Quarkus](#tab/quarkus)
19-
20-
:::image type="content" source="../../media/quickstart-java/quarkus-hello-world-in-browser-azure-app-service.png" alt-text="Screenshot of Quarkus Hello World web app running in Azure App Service in introduction.":::
21-
22-
### [Embedded Tomcat](#tab/embeddedtomcat)
23-
24-
:::image type="content" source="../../media/quickstart-java/embedded-tomcat-hello-world-in-browser-azure-app-service.png" alt-text="Screenshot of embedded Tomcat Hello World web app running in Azure App Service in introduction.":::
25-
26-
-----
27-
28-
If Maven isn't your preferred development tool, check out our similar tutorials for Java developers:
14+
If Maven isn't your preferred development tool, check out our other similar tutorials for Java developers:
2915
+ [Gradle](../../configure-language-java-deploy-run.md?pivots=platform-linux#gradle)
3016
+ [IntelliJ IDEA](/azure/developer/java/toolkit-for-intellij/create-hello-world-web-app)
3117
+ [Eclipse](/azure/developer/java/toolkit-for-eclipse/create-hello-world-web-app)
3218
+ [Visual Studio Code](https://code.visualstudio.com/docs/java/java-webapp)
3319

34-
[!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
20+
## Prerequisites
3521

36-
## 1 - Use Azure Cloud Shell
22+
- [!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
23+
- Run the Bash and Azure CLI commands in this tutorial by using Azure Cloud Shell, an interactive shell that you can use through your browser to work with Azure services. Select **Open Cloud Shell** at upper right in a code block and sign in to Azure if necessary. Then select **Copy** in the code block, paste the code into Cloud Shell, and run it.
3724

38-
[!INCLUDE [cloud-shell-try-it-no-header.md](~/reusable-content/ce-skilling/azure/includes/cloud-shell-try-it-no-header.md)]
25+
## Get the sample app
3926

40-
## 2 - Get the sample app
27+
Choose the appropriate tab and follow instructions to get the sample Spring Boot, Quarkus, or Embedded Tomcat web app.
4128

4229
### [Spring Boot](#tab/springboot)
4330

44-
1. Download and extract the [default Spring Boot web application template](https://github.com/rd-1-2022/rest-service). This repository is cloned for you when you run the [Spring CLI](https://docs.spring.io/spring-cli/reference/getting-started.html) command `spring boot new my-webapp`.
45-
46-
```bash
47-
git clone https://github.com/rd-1-2022/rest-service my-webapp
48-
```
31+
Download and extract the [default Spring Boot web application template](https://github.com/rd-1-2022/rest-service), or clone it by running the following command. Running the [Spring CLI](https://docs.spring.io/spring-cli/reference/getting-started.html) command `spring boot new my-webapp` also clones the web app.
4932

50-
1. Change your working directory to the project folder:
33+
```bash
34+
git clone https://github.com/rd-1-2022/rest-service my-webapp
35+
```
5136

52-
```azurecli-interactive
53-
cd my-webapp
54-
```
37+
Then change your working directory to the project folder by running `cd my-webapp`.
5538

5639
### [Quarkus](#tab/quarkus)
5740

58-
1. Generate a new Quarkus app named `quarkus-hello-azure` with the following Maven command:
41+
1. Generate a new Quarkus app named `quarkus-hello-azure` by running the following Maven command:
5942

60-
```azurecli-interactive
61-
mvn io.quarkus.platform:quarkus-maven-plugin:3.21.3:create \
62-
-DprojectGroupId=org.acme \
63-
-DprojectArtifactId=quarkus-hello-azure \
64-
-Dextensions='resteasy-reactive'
65-
```
66-
67-
1. Change your working directory to the project folder:
43+
```azurecli-interactive
44+
mvn io.quarkus.platform:quarkus-maven-plugin:3.21.3:create \
45+
-DprojectGroupId=org.acme \
46+
-DprojectArtifactId=quarkus-hello-azure \
47+
-Dextensions='resteasy-reactive'
48+
```
6849

69-
```azurecli-interactive
70-
cd quarkus-hello-azure
71-
```
50+
1. Change your working directory to the project folder by running `cd quarkus-hello-azure`.
7251

7352
### [Embedded Tomcat](#tab/embeddedtomcat)
7453

75-
1. Download and extract the [embeddedTomcatExample](https://github.com/Azure-Samples/java-docs-embedded-tomcat) repository, or clone it locally by running `git clone`:
54+
1. Download and extract the [embeddedTomcatExample](https://github.com/Azure-Samples/java-docs-embedded-tomcat) repository, or clone it locally by running the following `git clone` command.
7655

77-
```bash
78-
git clone https://github.com/Azure-Samples/java-docs-embedded-tomcat
79-
```
80-
81-
1. Change your working directory to the project folder:
56+
```bash
57+
git clone https://github.com/Azure-Samples/java-docs-embedded-tomcat
58+
```
8259

83-
```azurecli-interactive
84-
cd java-docs-embedded-tomcat
85-
```
60+
1. Change your working directory to the project folder by running `cd java-docs-embedded-tomcat`.
8661

87-
The application is run using the standard [Tomcat](https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/catalina/startup/Tomcat.html) class (see [Main.java](https://github.com/Azure-Samples/java-docs-embedded-tomcat/blob/main/src/main/java/com/microsoft/azure/appservice/examples/embeddedtomcat/Main.java) in the sample).
62+
1. Run the application by using the standard [Tomcat](https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/catalina/startup/Tomcat.html) class. See [Main.java](https://github.com/Azure-Samples/java-docs-embedded-tomcat/blob/main/src/main/java/com/microsoft/azure/appservice/examples/embeddedtomcat/Main.java) in the sample.
8863

8964
-----
9065

91-
## 3 - Configure the Maven plugin
66+
## Configure the Maven plugin
9267

9368
The deployment process to Azure App Service uses your Azure credentials from the Azure CLI automatically. If the Azure CLI isn't installed locally, then the Maven plugin authenticates with OAuth or device sign-in. For more information, see [authentication with Maven plugins](https://github.com/microsoft/azure-maven-plugins/wiki/Authentication).
9469

@@ -98,37 +73,39 @@ Run the Maven command shown next to configure the deployment. This command helps
9873
mvn com.microsoft.azure:azure-webapp-maven-plugin:2.14.1:config
9974
```
10075

101-
1. For **Create new run configuration**, type **Y**, then **Enter**.
102-
1. For **Define value for OS**, type **2** for Linux, then **Enter**.
103-
1. For **Define value for javaVersion**, type **1** for Java 21, then **Enter**.
104-
1. For **Define value for pricingTier**, type **3** for P1v2, then **Enter**.
105-
1. For **Confirm**, type **Y**, then **Enter**.
106-
107-
```
108-
Please confirm webapp properties
109-
AppName : <generated-app-name>
110-
ResourceGroup : <generated-app-name>-rg
111-
Region : centralus
112-
PricingTier : P1v2
113-
OS : Linux
114-
Java Version: Java 21
115-
Web server stack: Java SE
116-
Deploy to slot : false
117-
Confirm (Y/N) [Y]:
118-
[INFO] Saving configuration to pom.
119-
[INFO] ------------------------------------------------------------------------
120-
[INFO] BUILD SUCCESS
121-
[INFO] ------------------------------------------------------------------------
122-
[INFO] Total time: 47.533 s
123-
[INFO] Finished at: 2025-04-23T12:20:08Z
124-
[INFO] ------------------------------------------------------------------------
125-
```
126-
127-
After you confirm your choices, the plugin adds the above plugin element and requisite settings to your project's `pom.xml` file that configure your web app to run in Azure App Service.
128-
129-
The relevant portion of the `pom.xml` file should look similar to the following example.
130-
131-
```xml-interactive
76+
1. For **Create new run configuration**, type **Y** and then press **Enter**.
77+
1. For **Define value for OS**, type **2** for Linux, and then press **Enter**.
78+
1. For **Define value for javaVersion**, type **1** for Java 21, and then press **Enter**.
79+
1. For **Define value for pricingTier**, type **3** for P1v2, and then press **Enter**.
80+
1. For **Confirm**, type **Y** and then press **Enter**.
81+
82+
The output should look similar to the following code:
83+
84+
```bash
85+
Please confirm webapp properties
86+
AppName : <generated-app-name>
87+
ResourceGroup : <generated-app-name>-rg
88+
Region : centralus
89+
PricingTier : P1v2
90+
OS : Linux
91+
Java Version: Java 21
92+
Web server stack: Java SE
93+
Deploy to slot : false
94+
Confirm (Y/N) [Y]:
95+
[INFO] Saving configuration to pom.
96+
[INFO] ------------------------------------------------------------------------
97+
[INFO] BUILD SUCCESS
98+
[INFO] ------------------------------------------------------------------------
99+
[INFO] Total time: 47.533 s
100+
[INFO] Finished at: 2025-04-23T12:20:08Z
101+
[INFO] ------------------------------------------------------------------------
102+
```
103+
104+
After you confirm your choices, the plugin adds the plugin element and required settings to your project's *pom.xml* file, which configures your web app to run in App Service.
105+
106+
The relevant portion of the *pom.xml* file should look similar to the following example.
107+
108+
```xml
132109
<build>
133110
<plugins>
134111
<plugin>
@@ -137,113 +114,112 @@ The relevant portion of the `pom.xml` file should look similar to the following
137114
<version>x.xx.x</version>
138115
<configuration>
139116
<schemaVersion>v2</schemaVersion>
140-
<resourceGroup>your-resourcegroup-name</resourceGroup>
117+
<resourceGroup>your-resource-group-name</resourceGroup>
141118
<appName>your-app-name</appName>
142119
...
143120
</configuration>
144121
</plugin>
145122
</plugins>
146-
</build>
123+
</build>
147124
```
148125

149-
You can modify the configurations for App Service directly in your `pom.xml`.
126+
The values for `<appName>` and `<resourceGroup>` are used later.
127+
128+
You can modify the configurations for App Service directly in your *pom.xml* file.
150129

151130
- For the complete list of configurations, see [Common Configurations](https://github.com/microsoft/azure-maven-plugins/wiki/Common-Configuration).
152131
- For configurations specific to App Service, see [Azure Web App: Configuration Details](https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App:-Configuration-Details).
153132

154-
Be careful about the values of `<appName>` and `<resourceGroup>`. They're used later.
155-
156-
## 4 - Deploy the app
133+
## Deploy the app
157134

158-
With all the configuration ready in your [pom.xml](https://github.com/Azure-Samples/java-docs-embedded-tomcat/blob/main/pom.xml) file, you can deploy your Java app to Azure with one single command.
135+
With all the configuration ready in your [pom.xml](https://github.com/Azure-Samples/java-docs-embedded-tomcat/blob/main/pom.xml) file, you can deploy your Java app to Azure.
159136

160-
1. Build the JAR file using the following command(s):
137+
1. Build the JAR file using the following commands for Spring Boot, Quarkus, or Embedded Tomcat.
161138

162-
### [Spring Boot](#tab/springboot)
163-
164-
```bash
165-
mvn clean package
166-
```
167-
168-
> [!TIP]
169-
> Spring Boot produces two JAR files with `mvn package`, but `azure-webapp-maven-plugin` picks the right JAR file to deploy automatically.
170-
171-
### [Quarkus](#tab/quarkus)
172-
173-
```bash
174-
echo '%prod.quarkus.http.port=${PORT}' >> src/main/resources/application.properties
175-
mvn clean package -Dquarkus.package.jar.type=uber-jar
176-
```
177-
178-
In these commands:
179-
- You set the Quarkus port in the *application.properties* file to the PORT environment variable in the Linux Java container.
180-
- `quarkus.package.jar.type=uber-jar` tells Maven to [generate an Uber-Jar](https://quarkus.io/guides/maven-tooling#uber-jar-maven), which includes all dependencies in the JAR file.
181-
182-
> [!TIP]
183-
> Quarkus produces two JAR files with `mvn package`, but `azure-webapp-maven-plugin` picks the right JAR file to deploy automatically.
184-
185-
### [Embedded Tomcat](#tab/embeddedtomcat)
186-
187-
```bash
139+
### [Spring Boot](#tab/springboot)
140+
141+
```bash
188142
mvn clean package
189-
```
143+
```
190144

191-
To make the application it deployable using [azure-webapp-maven-plugin](https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App), and running on Azure App Service, the sample configures the `package` goal as follows:
192-
193-
- Build a single uber JAR file, which contains everything the application needs to run.
194-
- Create an [executable JAR](https://en.wikipedia.org/wiki/JAR_(file_format)#Executable_JAR_files) by specifying the Tomcat class as the start-up class.
195-
- Replace the original artifact with the uber JAR to ensure that the deploy step deploys the right file.
145+
> [!TIP]
146+
> Spring Boot produces two JAR files with `mvn package`, but the `azure-webapp-maven-plugin` picks the right JAR file to deploy automatically.
147+
148+
### [Quarkus](#tab/quarkus)
149+
150+
```bash
151+
echo '%prod.quarkus.http.port=${PORT}' >> src/main/resources/application.properties
152+
mvn clean package -Dquarkus.package.jar.type=uber-jar
153+
```
154+
155+
Set the Quarkus port in the *application.properties* file to the `PORT` environment variable in the Linux Java container. `Dquarkus.package.jar.type=uber-jar` tells Maven to [generate an Uber-Jar](https://quarkus.io/guides/maven-tooling#uber-jar-maven), which includes all dependencies in the JAR file.
156+
157+
> [!TIP]
158+
> Quarkus produces two JAR files with `mvn package`, but `azure-webapp-maven-plugin` picks the right JAR file to deploy automatically.
159+
160+
### [Embedded Tomcat](#tab/embeddedtomcat)
161+
162+
```bash
163+
mvn clean package
164+
```
165+
166+
To make the application deploy using [azure-webapp-maven-plugin](https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App) and run on Azure App Service, the sample configures the `package` goal as follows:
167+
168+
- Builds a single uber JAR file, which contains everything the application needs to run.
169+
- Creates an [executable JAR](https://en.wikipedia.org/wiki/JAR_(file_format)#Executable_JAR_files) by specifying the Tomcat class as the startup class.
170+
- Replaces the original artifact with the `Uber-Jar` to ensure that the deploy step deploys the right file.
196171

197172
-----
198173

199-
2. Deploy to Azure by using the following command:
174+
1. Deploy to Azure by using the following command:
200175

201176
```bash
202177
mvn azure-webapp:deploy
203178
```
204179

205-
Once you select from a list of available subscriptions, Maven deploys to Azure App Service. When the deployment completes, you see the following output:
180+
Once you select from a list of available subscriptions, Maven deploys to Azure App Service. When deployment completes, your application is ready, and you see the following output:
206181

207-
```output
208-
[INFO] Successfully deployed the artifact to <URL>
209-
[INFO] ------------------------------------------------------------------------
210-
[INFO] BUILD SUCCESS
211-
[INFO] ------------------------------------------------------------------------
212-
[INFO] Total time: 02:20 min
213-
[INFO] Finished at: 2023-07-26T12:47:50Z
214-
[INFO] ------------------------------------------------------------------------
215-
```
182+
```output
183+
[INFO] Successfully deployed the artifact to <URL>
184+
[INFO] ------------------------------------------------------------------------
185+
[INFO] BUILD SUCCESS
186+
[INFO] ------------------------------------------------------------------------
187+
[INFO] Total time: 02:20 min
188+
[INFO] Finished at: 2023-07-26T12:47:50Z
189+
[INFO] ------------------------------------------------------------------------
190+
```
216191

217-
Your application is ready.
192+
1. Open the Spring Boot< Quarkus, or Embedded Tomcat app as follows:
218193

219194
### [Spring Boot](#tab/springboot)
220195

221-
Get the default domain for your app in the Azure portal by selecting **Overview** for your app. Append `/greeting`. You should see:
196+
Open your app's default domain from the **Overview** page in the Azure portal, and append `/greeting` to the URL. You should see the following app:
222197

223198
:::image type="content" source="../../media/quickstart-java/springboot-hello-world-in-browser-azure-app-service.png" alt-text="Screenshot of Spring Boot Hello World web app running in Azure App Service.":::
224199

225200
### [Quarkus](#tab/quarkus)
226201

227-
Get the default domain for your app in the Azure portal by selecting **Overview** for your app. Append `/hello`. You should see:
202+
Open your app's default domain from the **Overview** in the Azure portal, and append `/hello` to the URL. You should see the following app:
228203

229204
:::image type="content" source="../../media/quickstart-java/quarkus-hello-world-in-browser-azure-app-service.png" alt-text="Screenshot of Quarkus web app running in Azure App Service.":::
230205

231206
### [Embedded Tomcat](#tab/embeddedtomcat)
232207

233-
Open the URL with your local web browser, and you should see:
208+
Open the URL for your app's default domain from the **Overview** in the Azure portal. You should see the following app:
234209

235210
:::image type="content" source="../../media/quickstart-java/embedded-tomcat-hello-world-in-browser-azure-app-service.png" alt-text="Screenshot of embedded Tomcat web app running in Azure App Service.":::
236211

237212
-----
238213

239-
**Congratulations!** You deployed your first Java app to App Service.
214+
Congratulations! You deployed a Java app to App Service.
240215

241-
## 5 - Clean up resources
216+
## Clean up resources
242217

243-
In the preceding steps, you created Azure resources in a resource group. If you don't need the resources in the future, delete the resource group from portal, or by running the following command in the Cloud Shell:
218+
You created the resources for this tutorial in an Azure resource group. If you no longer need them, you can delete the resource group and all its resources by running the following Azure CLI command in the Cloud Shell.
244219

245220
```azurecli-interactive
246-
az group delete --name <your resource group name; for example: quarkus-hello-azure-1690375364238-rg> --yes
221+
az group delete --name <your resource group name> --yes
247222
```
248223

249-
This command might take a minute to run.
224+
For example, run `az group delete --name quarkus-hello-azure-1690375364238-rg --yes`. This command might take awhile to run.
225+

0 commit comments

Comments
 (0)