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
In this quickstart, you'll 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
+
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 uses a [Quarkus](https://quarkus.io) sample, which comes with a bundled web server. You can deploy your own application and server bundle in a single JAR file to App Service instead of the using the Tomcat or JBoss hosting options. If you want, you can also embed a Tomcat server in the JAR file and run that in App Service.
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.
13
13
14
14
> [!NOTE]
15
-
> For Spring apps that requires all the Spring services, try [Azure Spring Apps](../../../spring-apps/enterprise/quickstart.md) instead. However, you can deploy Spring Boot apps to App Service.
15
+
> App Service can host Spring apps. For Spring apps that require all the Spring services, try [Azure Spring Apps](../../../spring-apps/quickstart.md) instead.
16
16
17
-
:::image type="content" source="../../media/quickstart-java/quarkus-hello-world-in-browser-azure-app-service.png" alt-text="Screenshot of Maven Hellow World web app running in Azure App Service in introduction.":::
17
+
### [Spring Boot](#tab/springboot)
18
+
19
+
:::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.":::
20
+
21
+
### [Embedded Tomcat](#tab/embeddedtomcat)
22
+
23
+
:::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.":::
24
+
25
+
### [Quarkus](#tab/quarkus)
26
+
27
+
:::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.":::
28
+
29
+
-----
18
30
19
31
If Maven isn't your preferred development tool, check out our similar tutorials for Java developers:
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/creating-new-projects.html) command `spring boot new my-webapp`.
41
48
42
-
Then change your working directory to the project folder:
1. Change your working directory to the project folder:
54
+
55
+
```azurecli-interactive
56
+
cd my-webapp
57
+
```
58
+
59
+
### [Embedded Tomcat](#tab/embeddedtomcat)
60
+
61
+
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:
68
+
69
+
```azurecli-interactive
70
+
cd java-docs-embedded-tomcat
71
+
```
72
+
73
+
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).
74
+
75
+
### [Quarkus](#tab/quarkus)
76
+
77
+
1. Generate a new Quarkus app named `quarkus-hello-azure` with the following Maven command:
1. Change your working directory to the project folder:
87
+
88
+
```azurecli-interactive
89
+
cd quarkus-hello-azure
90
+
```
91
+
92
+
-----
47
93
48
94
## 3 - Configure the Maven plugin
49
95
@@ -52,7 +98,7 @@ The deployment process to Azure App Service uses your Azure credentials from the
52
98
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.
After you've confirmed 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.
130
+
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.
85
131
86
132
The relevant portion of the `pom.xml` file should look similar to the following example.
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).
120
166
121
-
Be careful about the values of `<appName>` and `<resourceGroup>` (`quarkus-hello-azure-1690375364238` and `quarkus-hello-azure-1690375364238-rg` accordingly in the demo). They're used later.
167
+
Be careful about the values of `<appName>` and `<resourceGroup>`. They're used later.
122
168
123
169
## 4 - Deploy the app
124
170
125
-
With all the configuration ready in your *pom.xml* file, you can deploy your Java app to Azure with one single command.
171
+
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.
172
+
173
+
1. Build the JAR file using the following command:
174
+
175
+
### [Spring Boot](#tab/springboot)
176
+
177
+
```bash
178
+
mvn clean package
179
+
```
180
+
181
+
### [Embedded Tomcat](#tab/embeddedtomcat)
182
+
183
+
```bash
184
+
mvn clean package
185
+
```
186
+
187
+
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:
188
+
189
+
- Build a single uber JAR file, which contains everything the application needs to run.
190
+
- 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.
191
+
- Replace the original artifact with the uber JAR to ensure that the deploy step deploys the right file.
126
192
127
-
1. Rebuild the JAR file using the following command:
193
+
> [!TIP]
194
+
> 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.
Once deployment is completed, your application is ready at `http://<appName>.azurewebsites.net/` (`http://quarkus-hello-azure-1690375364238.azurewebsites.net` in the demo). Open the url with your local web browser, you should see
229
+
### [Spring Boot](#tab/springboot)
230
+
231
+
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:
232
+
233
+
:::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.":::
234
+
235
+
### [Embedded Tomcat](#tab/embeddedtomcat)
236
+
237
+
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:
238
+
239
+
:::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.":::
240
+
241
+
### [Quarkus](#tab/quarkus)
242
+
243
+
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:
244
+
245
+
:::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.":::
159
246
160
-
:::image type="content" source="../../media/quickstart-java/quarkus-hello-world-in-browser-azure-app-service.png" alt-text="Screenshot of Maven Hellow World web app running in Azure App Service.":::
247
+
-----
161
248
162
-
**Congratulations!** You've deployed your first Java app to App Service.
249
+
**Congratulations!** You deployed your first Java app to App Service.
163
250
164
251
## 5 - Clean up resources
165
252
@@ -169,4 +256,4 @@ In the preceding steps, you created Azure resources in a resource group. If you
169
256
az group delete --name <your resource group name; for example: quarkus-hello-azure-1690375364238-rg> --yes
0 commit comments