Quickstart: Create a Java web app in App Service on Linux

App Service on Linux currently provides a preview feature to support Java web apps. Please review the Supplemental Terms of Use for Microsoft Azure Previews for more information on previews.

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 Maven Plugin for Azure Web Apps (Preview) to deploy a Java web app with a built-in Linux image.

Sample app running in Azure

Deploying Java web apps to a Linux container in the cloud using the Azure Toolkit for IntelliJ is an alternative approach to deploy your Java app to your own container.

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


To complete this quickstart:

Create a Java app

Execute the following command using Maven to create a new helloworld web app:

mvn archetype:generate -DgroupId=example.demo -DartifactId=helloworld -DarchetypeArtifactId=maven-archetype-webapp

Change to the new helloworld project directory and build all modules using the following command:

mvn verify

This command will verify and create all modules including the helloworld.war file in the helloworld/target subdirectory.

Deploying the Java app to App Service on Linux

There are multiple deployment options for deploying your Java web apps to App Service on Linux. These options include:

In this quickstart, you will use the Maven plugin for Azure web apps. It has advantages in that it is easy to use from Maven, and creates the necessary Azure resources for you (resource group, app service plan, and web app).

Deploy with Maven

To deploy from Maven, add the following plugin definition inside the <build> element of the pom.xml file:

          <linuxRuntime>tomcat 9.0-jre8</linuxRuntime>

Update the following placeholders in the plugin configuration:

Placeholder Description
YOUR_RESOURCE_GROUP Name for the new resource group in which to create your web app. By putting all the resources for an app in a group, you can manage them together. For example, deleting the resource group would delete all resources associated with the app. Update this value with a unique new resource group name, for example, TestResources. You will use this resource group name to clean up all Azure resources in a later section.
YOUR_WEB_APP The app name will be part the host name for the web app when deployed to Azure (YOUR_WEB_APP.azurewebsites.net). Update this value with a unique name for the new Azure web app, which will host your Java app, for example contoso.

The linuxRuntime element of the configuration controls what built-in Linux image is used with your application.

Execute the following command and follow all directions to authenticate with the Azure CLI:

az login

Deploy your Java app to the web app using the following command:

mvn clean package azure-webapp:deploy

Once deployment has completed, browse to the deployed application using the following URL in your web browser.


The Java sample code is running in a web app with built-in image.

Sample app running in Azure

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 by running the following command in the Cloud Shell:

az group delete --name myResourceGroup

This command may take a minute to run.

Next steps

In this quickstart, you used Maven to create a Java web app, then you deployed the Java web app to App Service on Linux. To learn more about using Java with Azure, follow the link below.