Quickstart: Create a Java app on Azure App Service on Linux

App Service on Linux provides a highly scalable, self-patching, web hosting service using the Linux operating system. This quickstart shows how to use the Azure CLI with the Azure Web App Plugin for Maven to deploy a Java web archive (WAR) file on the Linux operating system.


The same thing can also be done using popular IDEs like IntelliJ, Eclipse and VS Code. Check out our similar documents at Azure Toolkit for IntelliJ Quickstart, Azure Toolkit for Eclipse Quickstart or VS Code Quickstart.

Sample app running in Azure App Service

If you don't have an Azure subscription, create a free account before you begin.

Use Azure Cloud Shell

Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this article without having to install anything on your local environment.

To start Azure Cloud Shell:

Option Example/Link
Select Try It in the upper-right corner of a code block. Selecting Try It doesn't automatically copy the code to Cloud Shell. Example of Try It for Azure Cloud Shell
Go to https://shell.azure.com, or select the Launch Cloud Shell button to open Cloud Shell in your browser. Launch Cloud Shell in a new window
Select the Cloud Shell button on the menu bar at the upper right in the Azure portal. Cloud Shell button in the Azure portal

To run the code in this article in Azure Cloud Shell:

  1. Start Cloud Shell.

  2. Select the Copy button on a code block to copy the code.

  3. Paste the code into the Cloud Shell session by selecting Ctrl+Shift+V on Windows and Linux or by selecting Cmd+Shift+V on macOS.

  4. Select Enter to run the code.

Create a Java app

Execute the following Maven command in the Cloud Shell prompt to create a new app named helloworld:

mvn archetype:generate "-DgroupId=example.demo" "-DartifactId=helloworld" "-DarchetypeArtifactId=maven-archetype-webapp" "-Dversion=1.0-SNAPSHOT"

Then change your working directory to the project folder:

cd helloworld

Configure the Maven plugin

The deploy process to Azure App Service can pickup your Azure credentials from the Azure CLI automatically. If you don't have Azure CLI installed, Maven plugin will sign you in with Oauth or device login. Check details on authentication with Maven plugins if you need.

To configure the deployment, run the maven command in the Command Prompt and use the default configurations by pressing ENTER until you get the Confirm (Y/N) prompt, then press 'y' and the configuration is done.

mvn com.microsoft.azure:azure-webapp-maven-plugin:1.9.1:config

A sample process looks like:

~@Azure:~/helloworld$ mvn com.microsoft.azure:azure-webapp-maven-plugin:1.9.1:config
[INFO] Scanning for projects...
[INFO] ----------------------< example.demo:helloworld >-----------------------
[INFO] Building helloworld Maven Webapp 1.0-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO] --- azure-webapp-maven-plugin:1.9.1:config (default-cli) @ helloworld ---
[WARNING] The plugin may not work if you change the os of an existing webapp.
Define value for OS(Default: Linux):
1. linux [*]
2. windows
3. docker
Enter index to use:
Define value for javaVersion(Default: jre8):
1. Java 11
2. Java 8 [*]
Enter index to use:
Define value for runtimeStack(Default: TOMCAT 8.5):
1. TOMCAT 9.0
2. TOMCAT 8.5 [*]
Enter index to use:
Please confirm webapp properties
AppName : helloworld-1558400876966
ResourceGroup : helloworld-1558400876966-rg
Region : westeurope
PricingTier : Premium_P1V2
OS : Linux
RuntimeStack : TOMCAT 8.5-jre8
Deploy to slot : false
Confirm (Y/N)? : Y


In this article we are only working with Java apps packaged in WAR files. The plugin also supports JAR web applications, visit Deploy a Java SE JAR file to App Service on Linux to try it out.

Open to pom.xml to see the updated configuration.

code pom.xml

You can modify the configurations for App Service directly in your pom file if needed, some common ones are listed below:

Property Required Description Version
<schemaVersion> false Specify the version of the configuration schema. Supported values are: v1, v2. 1.5.2
<resourceGroup> true Azure Resource Group for your Web App. 0.1.0+
<appName> true The name of your Web App. 0.1.0+
<region> true Specifies the region where your Web App will be hosted; the default value is westeurope. All valid regions at Supported Regions section. 0.1.0+
<pricingTier> false The pricing tier for your Web App. The default value is P1V2. 0.1.0+
<runtime> true The runtime environment configuration, you could see the detail here. 0.1.0+
<deployment> true The deployment configuration, you could see the details here. 0.1.0+

Deploy the app

Deploy your Java app to Azure using the following command:

mvn package azure-webapp:deploy

Once deployment has completed, browse to the deployed application using the following URL in your web browser, for example http://<webapp>.azurewebsites.net.

Sample app running in Azure App Service

Congratulations! You've deployed your first Java app to App Service on Linux.

Clean up resources

In the preceding steps, you created Azure resources in a resource group. If you don't expect to need these resources in the future, delete the resource group from portal, or by running the following command in the Cloud Shell:

az group delete --name <your resource group name; for example: helloworld-1558400876966-rg> --yes

This command may take a minute to run.

Next steps