| Order | 2 |
|---|---|
| Area | java |
| TOCTitle | Java Web App |
| ContentId | 98ddf1d3-6a8e-4b0f-a44d-e57cfdf2348c |
| PageTitle | Deploy Java Web Apps to the cloud |
| DateApproved | 11/14/2017 |
| MetaDescription | Java web app tutorial showing how to deploy a Java web app to Azure |
| MetaSocialImage | TBD |
In our first tutorial, we've build a Java web app running locally. This tutorial will show you how to run it in the cloud.
Before running this sample on Azure, you need to have an Azure subscription and the command line tools.
If you don't have an Azure subscription, you can sign up for a free Azure account:
Create your free Azure account
The Azure Command-Line Interface (CLI):
We'll use the Integrated Terminal in VS Code. To open the terminal you can either:
- Use the
kb(workbench.action.terminal.toggleTerminal)keyboard shortcut with the backtick character. - Use the View | Integrated Terminal menu command.
- From the Command Palette (
kb(workbench.action.showCommands)), use the View:Toggle Integrated Terminal command.
Note: You can still open an external shell with the Explorer Open in Command Prompt command (Open in Terminal on Mac or Linux) if you prefer to work outside VS Code.
Sign into your Azure account by using the Azure CLI:
az loginFollow the instructions to complete the sign-in process.
Open your pom.xml file in your project folder (complete). Find and remove the snippet below in azure-webapp-maven-plugin configuration section so we will authenticate with Azure using Azure CLI, which we've already logged in with.
Note: This specific configuration will instead using Service Principal for authentication. More details could be found at Configure Maven to use your Azure Service Principal
From the command prompt or terminal window that you were using earlier, rebuild the JAR file using Maven if you made any changes to the pom.xml file; for example:
mvn clean packageDeploy your web app to Azure by using Maven; for example:
mvn azure-webapp:deployMaven will deploy your web app to Azure; if the web app does not already exist, it will be created.
When your web has been deployed, you will see a success message from command Line
by pasting the URL to browser, you will see the sample web app running on Azure!
You will also be able to manage it by using the Azure portal.
Your web app will be listed in App Services:
And the URL for your web app will be listed in the Overview for your web app:
You have successfully built a Java web application running in the cloud!
- To see how you can containerize the app and deploy to the cloud, check out Java Container Tutorial
- To learn more about Java Debugging features, see Java Debugging Tutorial




