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 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.
11
11
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).
13
13
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:
- 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.
Choose the appropriate tab and follow instructions to get the sample Spring Boot, Quarkus, or Embedded Tomcat web app.
41
28
42
29
### [Spring Boot](#tab/springboot)
43
30
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`.
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.
49
32
50
-
1. Change your working directory to the project folder:
1. Change your working directory to the project folder by running `cd quarkus-hello-azure`.
72
51
73
52
### [Embedded Tomcat](#tab/embeddedtomcat)
74
53
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.
1. Change your working directory to the project folder by running `cd java-docs-embedded-tomcat`.
86
61
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.
88
63
89
64
-----
90
65
91
-
## 3 - Configure the Maven plugin
66
+
## Configure the Maven plugin
92
67
93
68
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).
94
69
@@ -98,37 +73,39 @@ Run the Maven command shown next to configure the deployment. This command helps
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:
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
132
109
<build>
133
110
<plugins>
134
111
<plugin>
@@ -137,113 +114,112 @@ The relevant portion of the `pom.xml` file should look similar to the following
You can modify the configurations forApp Service directlyin 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.
150
129
151
130
- For the complete list of configurations, see [Common Configurations](https://github.com/microsoft/azure-maven-plugins/wiki/Common-Configuration).
152
131
- 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).
153
132
154
-
Be careful about the values of `<appName>` and `<resourceGroup>`. They're used later.
155
-
156
-
## 4 - Deploy the app
133
+
## Deploy the app
157
134
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.
159
136
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.
161
138
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.
- 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
188
142
mvn clean package
189
-
```
143
+
```
190
144
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.
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.
196
171
197
172
-----
198
173
199
-
2. Deploy to Azure by using the following command:
174
+
1. Deploy to Azure by using the following command:
200
175
201
176
```bash
202
177
mvn azure-webapp:deploy
203
178
```
204
179
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:
206
181
207
-
```output
208
-
[INFO] Successfully deployed the artifact to <URL>
1. Open the Spring Boot< Quarkus, or Embedded Tomcat app as follows:
218
193
219
194
### [Spring Boot](#tab/springboot)
220
195
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:
222
197
223
198
:::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.":::
224
199
225
200
### [Quarkus](#tab/quarkus)
226
201
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:
228
203
229
204
:::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.":::
230
205
231
206
### [Embedded Tomcat](#tab/embeddedtomcat)
232
207
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:
234
209
235
210
:::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.":::
236
211
237
212
-----
238
213
239
-
**Congratulations!** You deployed your first Java app to App Service.
214
+
Congratulations! You deployed a Java app to App Service.
240
215
241
-
## 5 - Clean up resources
216
+
## Clean up resources
242
217
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 commandin 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.
244
219
245
220
```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
247
222
```
248
223
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.
0 commit comments