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
Copy file name to clipboardExpand all lines: articles/app-service/includes/quickstart-java/quickstart-java-javase.md
+58-65Lines changed: 58 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,26 @@ author: cephalin
3
3
ms.service: azure-app-service
4
4
ms.devlang: java
5
5
ms.topic: include
6
-
ms.date: 02/10/2024
6
+
ms.date: 04/23/2025
7
7
ms.author: cephalin
8
8
---
9
9
10
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.
11
11
12
-
The quickstart deploys either a Spring Boot app, embedded Tomcat, or Quarkus app using the [azure-webapp-maven-plugin](https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App) plugin.
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.
13
13
14
14
### [Spring Boot](#tab/springboot)
15
15
16
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
17
18
-
### [Embedded Tomcat](#tab/embeddedtomcat)
19
-
20
-
:::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.":::
21
-
22
18
### [Quarkus](#tab/quarkus)
23
19
24
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.":::
25
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
26
-----
27
27
28
28
If Maven isn't your preferred development tool, check out our similar tutorials for Java developers:
@@ -53,39 +53,39 @@ If Maven isn't your preferred development tool, check out our similar tutorials
53
53
cd my-webapp
54
54
```
55
55
56
-
### [Embedded Tomcat](#tab/embeddedtomcat)
56
+
### [Quarkus](#tab/quarkus)
57
57
58
-
1. Download and extract the [embeddedTomcatExample](https://github.com/Azure-Samples/java-docs-embedded-tomcat) repository, or clone it locally by running `git clone`:
58
+
1. Generate a new Quarkus app named `quarkus-hello-azure` with the following Maven command:
1. Change your working directory to the project folder:
65
68
66
69
```azurecli-interactive
67
-
cdjava-docs-embedded-tomcat
70
+
cdquarkus-hello-azure
68
71
```
69
72
70
-
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).
71
-
72
-
### [Quarkus](#tab/quarkus)
73
+
### [Embedded Tomcat](#tab/embeddedtomcat)
73
74
74
-
1. Generate a new Quarkus app named `quarkus-hello-azure` with the following Maven command:
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`:
1. Change your working directory to the project folder:
84
82
85
83
```azurecli-interactive
86
-
cdquarkus-hello-azure
84
+
cdjava-docs-embedded-tomcat
87
85
```
88
86
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).
88
+
89
89
-----
90
90
91
91
## 3 - Configure the Maven plugin
@@ -95,12 +95,12 @@ The deployment process to Azure App Service uses your Azure credentials from the
95
95
Run the Maven command shown next to configure the deployment. This command helps you to set up the App Service operating system, Java version, and Tomcat version.
@@ -146,35 +146,42 @@ The relevant portion of the `pom.xml` file should look similar to the following
146
146
</build>
147
147
```
148
148
149
-
You can modify the configurations forApp Service directlyin your `pom.xml`. Some common configurations are listed in the following table:
149
+
You can modify the configurations forApp Service directlyin your `pom.xml`.
150
150
151
-
Property | Required | Description | Version
152
-
---|---|---|---
153
-
`<schemaVersion>`|false| Specify the version of the configuration schema. Supported values are: `v1`, `v2`. | 1.5.2
154
-
`<subscriptionId>`|false| Specify the subscription ID. | 0.1.0+
155
-
`<resourceGroup>`|true| Azure Resource Group for your Web App. | 0.1.0+
156
-
`<appName>`|true| The name of your Web App. | 0.1.0+
157
-
`<region>`|false| Specifies the region to host your Web App; the default value is **centralus**. All valid regions at [Supported Regions](https://azure.microsoft.com/global-infrastructure/services/?products=app-service) section. | 0.1.0+
158
-
`<pricingTier>`|false| The pricing tier for your Web App. The default value is **P1v2**for production workload, while**B2** is the recommended minimum for Java dev/test. For more information, see [App Service Pricing](https://azure.microsoft.com/pricing/details/app-service/linux/)| 0.1.0+
159
-
`<runtime>`|false| The runtime environment configuration. For more information, see [Configuration Details](https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App:-Configuration-Details). | 0.1.0+
160
-
`<deployment>`|false| The deployment configuration. For more information, see [Configuration Details](https://github.com/microsoft/azure-maven-plugins/wiki/Azure-Web-App:-Configuration-Details). | 0.1.0+
161
-
162
-
For the complete list of configurations, see the plugin reference documentation. All the Azure Maven Plugins share a common set of configurations. For these configurations see [Common Configurations](https://github.com/microsoft/azure-maven-plugins/wiki/Common-Configuration). 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).
151
+
- For the complete list of configurations, see [Common Configurations](https://github.com/microsoft/azure-maven-plugins/wiki/Common-Configuration).
152
+
- 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).
163
153
164
154
Be careful about the values of `<appName>` and `<resourceGroup>`. They're used later.
165
155
166
156
## 4 - Deploy the app
167
157
168
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.
169
159
170
-
1. Build the JAR file using the following command:
160
+
1. Build the JAR file using the following command(s):
171
161
172
162
### [Spring Boot](#tab/springboot)
173
163
174
164
```bash
175
165
mvn clean package
176
166
```
177
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.
- You set the Quarkus port in the *application.properties* file to match the default port that the Linux Java container uses.
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
+
178
185
### [Embedded Tomcat](#tab/embeddedtomcat)
179
186
180
187
```bash
@@ -187,22 +194,6 @@ With all the configuration ready in your [pom.xml](https://github.com/Azure-Samp
187
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.
188
195
- Replace the original artifact with the uber JAR to ensure that the deploy step deploys the right file.
189
196
190
-
> [!TIP]
191
-
> Quarkus and Spring Boot both produce two JAR files with `mvn clean package`, but `azure-webapp-maven-plugin` picks the right JAR file to deploy automatically.
- `quarkus.package.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.
202
-
- `%prod.quarkus.http.port=80` tells Quarkus to use port 80 for the prod environment at runtime, which is the default port that the Linux Java container uses. If you want, you can change the port number of the Java container with the `WEBSITES_PORT` app setting.
203
-
204
-
You can configure these properties by using other means, but they're added to `mvn package`command here for simplicity.
205
-
206
197
-----
207
198
208
199
2. Deploy to Azure by using the following command:
@@ -211,7 +202,7 @@ With all the configuration ready in your [pom.xml](https://github.com/Azure-Samp
211
202
mvn azure-webapp:deploy
212
203
```
213
204
214
-
If the deployment succeeds, you see the following output:
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:
215
206
216
207
```output
217
208
[INFO] Successfully deployed the artifact to https://<app-name>.azurewebsites.net
@@ -223,23 +214,25 @@ With all the configuration ready in your [pom.xml](https://github.com/Azure-Samp
Your application is ready at `http://<appName>.azurewebsites.net/`.
218
+
226
219
### [Spring Boot](#tab/springboot)
227
220
228
-
Once deployment is completed, your application is ready at `http://<appName>.azurewebsites.net/`. Open the URL `http://<appName>.azurewebsites.net/greeting` with your local web browser (note the `/greeting` path), and you should see:
221
+
Open the URL `http://<appName>.azurewebsites.net/greeting` with your local web browser (note the `/greeting` path), and you should see:
229
222
230
223
:::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.":::
231
224
232
-
### [Embedded Tomcat](#tab/embeddedtomcat)
225
+
### [Quarkus](#tab/quarkus)
233
226
234
-
Once deployment is completed, your application is ready at `http://<appName>.azurewebsites.net/`. Open the url with your local web browser, and you should see:
227
+
Open the URL `http://<appName>.azurewebsites.net/hello` with your local web browser (note the `/hello` path), and you should see:
235
228
236
-
:::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.":::
229
+
:::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.":::
237
230
238
-
### [Quarkus](#tab/quarkus)
231
+
### [Embedded Tomcat](#tab/embeddedtomcat)
239
232
240
-
Once deployment is completed, your application is ready at `http://<appName>.azurewebsites.net/`. Open the url with your local web browser, and you should see:
233
+
Open the URLl with your local web browser, and you should see:
241
234
242
-
:::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.":::
235
+
:::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.":::
0 commit comments