Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this quickstart, you'll use the Maven Plugin for Azure App Service Web Apps to deploy a Java web application to a Linux Tomcat server in 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.
If Maven isn't your preferred development tool, check out our similar tutorials for Java developers:
If you don't have an Azure subscription, create a trial account before you begin.
Execute the following Maven command in the cli prompt to create a new app named helloworld
:
mvn archetype:generate "-DgroupId=example.demo" "-DartifactId=helloworld" "-DarchetypeArtifactId=maven-archetype-webapp" "-DarchetypeVersion=1.4" "-Dversion=1.0-SNAPSHOT"
Then change your working directory to the project folder:
cd helloworld
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.
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.
mvn com.microsoft.azure:azure-webapp-maven-plugin:2.14.1:config
For Create new run configuration, type Y, then Enter.
For Define value for OS, type 1 for Windows, or 2 for Linux, then Enter.
For Define value for javaVersion, type 1 for Java 21, then Enter.
For Define value for webContainer, type 1 for Tomcat 10.1, then Enter.
For Define value for pricingTier, type 3 for P1V2, then Enter.
For Confirm, type Y, then Enter.
Please confirm webapp properties AppName : helloworld-1745408005556 ResourceGroup : helloworld-1745408005556-rg Region : chinanorth2 PricingTier : P1V2 OS : Linux Java Version: Java 21 Web server stack: Tomcat 10.1 Deploy to slot : false Confirm (Y/N) [Y]: [INFO] Saving configuration to pom. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:36 min [INFO] Finished at: 2025-04-23T11:34:44Z [INFO] ------------------------------------------------------------------------
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.
The relevant portion of the pom.xml
file should look similar to the following example.
<build>
<plugins>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>>azure-webapp-maven-plugin</artifactId>
<version>x.xx.x</version>
<configuration>
<schemaVersion>v2</schemaVersion>
<resourceGroup>your-resourcegroup-name</resourceGroup>
<appName>your-app-name</appName>
...
</configuration>
</plugin>
</plugins>
</build>
You can modify the configurations for App Service directly in your pom.xml
.
- For the complete list of configurations, see Common Configurations.
- For configurations specific to App Service, see Azure Web App: Configuration Details.
Be careful about the values of <appName>
and <resourceGroup>
(helloworld-1745408005556
and helloworld-1745408005556-rg
accordingly in the demo). They're used later.
With all the configuration ready in your pom.xml file, you can deploy your Java app to Azure with one single command.
mvn package azure-webapp:deploy
Once you select from a list of available subscriptions, Maven deploys to Azure App Service. When deployment completes, your application is ready at http://<appName>.chinacloudsites.cn/
(http://helloworld-1745408005556.chinacloudsites.cn
in the demo). Open the URL with your local web browser, you should see
Congratulations! You've deployed your first Java app to App Service.
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 Cli:
az group delete --name <your resource group name; for example: helloworld-1745408005556-rg> --yes
This command may take a minute to run.
In this quickstart, you use the Maven Plugin for Azure App Service Web Apps to deploy a Java web application with an embedded server to Azure App Service. App Service provides a highly scalable, self-patching web app hosting service. Use the tabs to switch between Tomcat, or embedded server (Java SE) instructions.
The quickstart deploys either a Spring Boot app, embedded Tomcat, or Quarkus app using the azure-webapp-maven-plugin plugin.
If Maven isn't your preferred development tool, check out our similar tutorials for Java developers:
If you don't have an Azure subscription, create a trial account before you begin.
Download and extract the default Spring Boot web application template. This repository is cloned for you when you run the Spring CLI command
spring boot new my-webapp
.git clone https://github.com/rd-1-2022/rest-service my-webapp
Change your working directory to the project folder:
cd my-webapp
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.
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.
mvn com.microsoft.azure:azure-webapp-maven-plugin:2.14.1:config
For Create new run configuration, type Y, then Enter.
For Define value for OS, type 2 for Linux, then Enter.
For Define value for javaVersion, type 1 for Java 21, then Enter.
For Define value for pricingTier, type 3 for P1v2, then Enter.
For Confirm, type Y, then Enter.
Please confirm webapp properties AppName : <generated-app-name> ResourceGroup : <generated-app-name>-rg Region : chinanorth2 PricingTier : P1v2 OS : Linux Java Version: Java 21 Web server stack: Java SE Deploy to slot : false Confirm (Y/N) [Y]: [INFO] Saving configuration to pom. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 47.533 s [INFO] Finished at: 2025-04-23T12:20:08Z [INFO] ------------------------------------------------------------------------
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.
The relevant portion of the pom.xml
file should look similar to the following example.
<build>
<plugins>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>>azure-webapp-maven-plugin</artifactId>
<version>x.xx.x</version>
<configuration>
<schemaVersion>v2</schemaVersion>
<resourceGroup>your-resourcegroup-name</resourceGroup>
<appName>your-app-name</appName>
...
</configuration>
</plugin>
</plugins>
</build>
You can modify the configurations for App Service directly in your pom.xml
.
- For the complete list of configurations, see Common Configurations.
- For configurations specific to App Service, see Azure Web App: Configuration Details.
Be careful about the values of <appName>
and <resourceGroup>
. They're used later.
With all the configuration ready in your pom.xml file, you can deploy your Java app to Azure with one single command.
Build the JAR file using the following command(s):
mvn clean package
Tip
Spring Boot produces two JAR files with
mvn package
, butazure-webapp-maven-plugin
picks the right JAR file to deploy automatically.Deploy to Azure by using the following command:
mvn azure-webapp:deploy
Once you select from a list of available subscriptions, Maven deploys to Azure App Service. When the deployment completes, you see the following output:
[INFO] Successfully deployed the artifact to https://<app-name>.chinacloudsites.cn [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 02:20 min [INFO] Finished at: 2023-07-26T12:47:50Z [INFO] ------------------------------------------------------------------------
Your application is ready at
http://<appName>.chinacloudsites.cn/
.
Open the URL http://<appName>.chinacloudsites.cn/greeting
with your local web browser (note the /greeting
path), and you should see:
Congratulations! You deployed your first Java app to App Service.
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 local Shell:
az group delete --name <your resource group name; for example: quarkus-hello-azure-1690375364238-rg> --yes
This command might take a minute to run.