Deploy Java Web Apps to the cloud
In our first tutorial, we built a Java web application and ran it locally. In this tutorial, you will learn how to deploy from Visual Studio Code and run it on Azure in the cloud.
Prerequisites
- Java Developer Kit (JDK), version 1.8 or above.
- Apache Maven, version 3.0 or above.
Important: The
JAVA_HOMEenvironment variable must be set to the install location of the JDK to complete this tutorial.
Install the Azure App Service extension
The Azure App Service extension is used to create, manage, and deploy to Azure App Service with key features including:
- Create new Azure Web App/Deployment Slot
- Deploy to Azure Web App/Deployment Slot
- Start, stop, and restart the Azure Web App/Deployment Slot
- View a Web App's log files
- Swap Deployment Slots
To install the Azure App Service extension, open the Extensions view (⇧⌘X (Windows, Linux Ctrl+Shift+X)) and search for azure app service to filter the results. Select the Microsoft Azure App Service extension. For a more command line Maven-centric experience, you can also check out the Maven plugin for Azure App Service Linux tutorial.
Create a new Web App
Once the extension is installed, you can take the following steps to create a new Web App.
- Click Create New Project button on the APP SERVICE Explorer view.
- Select a subscription.
- Enter a unique name for the new Web App.
- Select a location for the new Web App.
- Select the OS as
Linux. - Select the runtime of the Web App, e.g.
Tomcat 8.5 (JRE8).

Build and deploy to a Web App
If you don't have an Azure subscription, you can sign up for a free Azure account.
Create your free Azure account
The deploy process leverages the Azure Account extension (installed along with the Azure Functions extension as an dependency) and you need to sign in with your Azure subscription. If you do not have an Azure subscription, sign up today for a free 30 day account and get $200 in Azure Credits to try out any combination of Azure services.
To log into Azure, run Azure: Sign In from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)). You can then sign into your account using the Device Login flow. Click on Copy & Open to open your default browser.

Paste in the access code and continue the sign in process.

Once you have signed in, you can open the command prompt or terminal window and build the project using Maven commands. This will generate a new name.war or name.jar file in the target directory.
mvn clean package
After building the project, open the target directory in VS Code Explorer. Right-click on the name.war or name.jar file and choose Deploy to Web App, and follow the prompts to choose the Web App for your deployment.

Open the Output window in VS Code to view the deployment logs. Once the deployment is completed, it will print out the URL for your Web App. Click the link to open it in a browser, you can see the web app running on Azure!

Note: For more advanced features of App Service, you can check out the Azure App Service extension.
Next steps
- To containerize and deploy a web application, check out the Java Container Tutorial
- To learn more about Java Debugging features, see the Java Debugging Tutorial

