Create a Hello World web app for Azure App Service using IntelliJ
This article demonstrates the steps that are required to create a basic Hello World web app and publish your web app to Azure App Service by using the Azure Toolkit for IntelliJ.
If you prefer using Eclipse, check out our similar tutorial for Eclipse.
Don't forget to clean up the resources after you complete this tutorial. In that case, running this guide will not exceed your free account quota.
To complete the steps in this article, you will need to install the Azure Toolkit for IntelliJ, which requires the following software components:
- An Azure supported Java Development Kit (JDK)
- An IntelliJ IDEA Ultimate Edition or Community Edition installed
The Azure Toolkit for IntelliJ page at the JetBrains Plugin Repository lists the builds that are compatible with the toolkit.
Installation and sign-in
The following steps walk you through the Azure sign in process in your IntelliJ development environment.
If you haven't installed the plugin, see Installing the Azure Toolkit for IntelliJ.
To sign in to your Azure account, navigate to the left-hand Azure Explorer sidebar, and then click the Azure Sign In icon. Alternatively, you can navigate to Tools, expand Azure, and click Azure Sign in..
In the Azure Sign In window, select Device Login, and then click Sign in (other sign in options).
Click Copy&Open in the Azure Device Login dialog.
In the browser, paste your device code (which has been copied when you clicked Copy&Open in last step) and then click Next.
Select your Azure account and complete any authentication procedures necessary in order to sign in.
Once signed in, close your browser and switch back to your IntelliJ IDE. In the Select Subscriptions dialog box, select the subscriptions that you want to use, then click Select.
Creating a new web app project
Click File, expand New, and then click Project.
In the New Project dialog box, select Maven, and make sure the Create from Archetype option is checked. From the list, select maven-archetype-webapp, and then click Next.
Expand the Artifact Coordinates dropdown to view all input fields and specify the following information for your new web app and click Next:
- Name: The name of your web app. This will automatically fill in the web app's ArtifactId field.
- GroupId: The name of the artifact group, usually a company domain. (e.g. com.microsoft.azure)
- Version: We'll keep the default version 1.0-SNAPSHOT.
Customize any Maven settings or accept the defaults, and then click Finish.
Navigate to your project on the left-hand Project tab, and open the file src/main/webapp/index.jsp. Replace the code with the following and save the changes:
<html> <body> <b><% out.println("Hello World!"); %></b> </body> </html>
Deploying web app to Azure
Under the Project Explorer view, right-click your project, expand Azure, then click Deploy to Azure Web Apps.
In the Deploy to Azure dialog box, you can deploy the application to an existing Tomcat webapp or you can create a new one.
a. Click No available webapp, click to create a new one to create a new webapp. Otherwise, choose Create New WebApp from the WebApp dropdown if there are existing webapps in your subscription.
In the pop-up Create WebApp dialog box, specify the following information and click OK:
- Name: The WebApp's domain name string.
- Subscription: Specifies the Azure subscription that you want to use for the new WebApp.
- Platform: Select Linux.
- Web Container: Select TOMCAT 9.0-jre8 or as appropriate.
- Resource Group: Specifies the resource group for your WebApp. You may select an existing resource group associated with your Azure account or create a new one.
- App Service Plan: Specifies the App Service Plan for your WebApp. You may select an existing plan associated with your Azure account or create a new one.
b. To deploy to an existing webapp, choose the web app from WebApp drop down, and then click Run.
The toolkit will display a status message when it has successfully deployed your web app, along with the URL of your deployed web app if succeed.
You can browse to your web app using the link provided in the status message.
Managing deploy configurations
After you have published your web app, you can run the deployment by clicking the green arrow icon on the toolbar.
Before running your WebApp's deployment, you can modify the default settings by clicking the drop-down menu for your web app and selecting Edit Configurations.
On the Run/Debug Configurations dialog box, you can modify any of the default settings. Click OK to save the settings.
Cleaning up resources
To delete your web app, navigate to the left-hand Azure Explorer sidebar and locate the Web Apps item.
If the Web Apps menu item does not expand, manually refresh the list by clicking the Refresh icon on the Azure Explorer toolbar, or by right-clicking the Web Apps menu item and selecting Refresh.
Right-click the web app you'd like to delete and click Delete.
To delete your app service plan or resource group, visit the Azure portal and manually delete the resources under your subscription.
For more information about using Java with Azure, see the following links:
- Azure for Java Developers
- Java with Azure DevOps Services
- Get Java JDK downloads and support when developing for Azure
For additional information about creating Azure Web Apps, see the Web Apps Overview.