Create a Hello World web app for Azure App Service using IntelliJ
Using open sourced Azure Toolkit for IntelliJ plugin, creating and deploying a basic Hello World application to Azure App Service as a web app can be done in a few minutes.
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 his 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
In IntelliJ IDEA's Settings/Preferences dialog (Ctrl+Alt+S), select Plugins. Then, find the Azure Toolkit for IntelliJ in the Marketplace and click Install. After installed, click Restart to activate the plugin.
To sign in to your Azure account, open sidebar Azure Explorer, and then click the Azure Sign In icon in the bar on top (or from IDEA menu Tools/Azure/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 Azure Device Login dialog .
In the browser, paste your device code (which has been copied when you click Copy&Open in last step) and then click Next.
In the Select Subscriptions dialog box, select the subscriptions that you want to use, and then click OK.
Creating web app project
In IntelliJ, click the File menu, then click New, and then click Project.
In the New Project dialog box, select Maven, then maven-archetype-webapp, and then click Next.
Specify the GroupId and ArtifactId for your web app, and then click Next.
Customize any Maven settings or accept the defaults, and then click Next.
Specify your project name and location, and then click Finish.
Under Project Explorer view, open and edit the file src/main/webapp/index.jsp as following and save the changes:
<html> <body> <b><% out.println("Hello World!"); %></b> </body> </html>
Deploying web app to Azure
Under Project Explorer view, right-click your project, expand Azure, then click Deploy to Azure.
In the Deploy to Azure dialog box, you can directly deploy the application to an existing Tomcat webapp if you already have one, otherwise you should create a new one first.
Click the link No Available webapp, click to create a new one to crete a new web app, you could choose Create New WebApp from WebApp dropdown if there are existing webapps in your subscription.
In the pop-up dialog box, chose TOMCAT 8.5-jre8 as Web Container and specify other required information, then click OK to create the webapp.
Choose the web app from WebApp drop down, and then click Run.(You could start from here if you want deploy to an existing webapp)
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, your settings will be saved as the default, and you can run the deployment by clicking the green arrow icon on the toolbar. You can modify your settings by clicking the drop-down menu for your web app and click Edit Configurations.
When the Run/Debug Configurations dialog box is displayed, you can modify any of the default settings, and then click OK.
Cleaning up resources
Deleting Web Apps in Azure Explorer
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.