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


This article deploys an app to App Service on Windows. To deploy to App Service on Linux, see Create Java web app on Linux.

Azure App Service provides a highly scalable, self-patching web hosting service. 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.


The same thing can also be done using popular IDEs like IntelliJ and Eclipse. Check out our similar documents at Azure Toolkit for IntelliJ Quickstart or Azure Toolkit for Eclipse 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

Configure the Maven plugin

To deploy from Maven, use the code editor in the Cloud Shell to open up the project pom.xml file in the helloworld directory.

code pom.xml

Then add the following plugin definition inside the <build> element of the pom.xml file.

    <!-- Deploy to Tomcat in App Service Windows         -->
            <!-- Specify v2 schema -->
            <!-- App information -->
            <!-- Java Runtime Stack for App Service on Windows-->
                <webContainer>tomcat 9.0</webContainer>


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.

Update the following placeholders in the plugin configuration:

Placeholder Description
SUBSCRIPTION_ID The unique ID of the subscription you want to deploy your app to. Default subscription's ID can be found from the Cloud Shell or CLI using the az account show command. For all the available subscriptions, use the az account list command.
RESOURCEGROUP_NAME Name for the new resource group in which to create your 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, myResourceGroup. You will use this resource group name to clean up all Azure resources in a later section.
WEBAPP_NAME The app name will be part of the host name for the app when deployed to Azure (WEBAPP_NAME.azurewebsites.net). Update this value with a unique name for the new App Service app, which will host your Java app, for example contoso.
REGION An Azure region where the app is hosted, for example westus2. You can get a list of regions from the Cloud Shell or CLI using the az account list-locations command.

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 Windows.

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