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.

Note

If you prefer using Eclipse, check out our similar tutorial for Eclipse.

If you don't have an Azure subscription, create a free account before you begin.

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.

Prerequisites

To complete the steps in his article, you will need to install the Azure Toolkit for IntelliJ, which requires the following software components:

Note

The Azure Toolkit for IntelliJ page at the JetBrains Plugin Repository lists the builds that are compatible with the toolkit.

Installation and Sign-in

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

    Azure Toolkit for IntelliJ plugin in Marketplace

  2. 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).

    The IntelliJ Azure Sign In command

  3. In the Azure Sign In window, select Device Login, and then click Sign in (other sign in options).

    The Azure Sign In window with device login selected

  4. Click Copy&Open in Azure Device Login dialog .

    The Azure Login Dialog window

  5. In the browser, paste your device code (which has been copied when you click Copy&Open in last step) and then click Next.

    The device login browser

  6. In the Select Subscriptions dialog box, select the subscriptions that you want to use, and then click OK.

    The Select Subscriptions dialog box

Creating web app project

  1. In IntelliJ, click the File menu, then click New, and then click Project.

    Create New Project

  2. In the New Project dialog box, select Maven, then maven-archetype-webapp, and then click Next.

    Choose Maven archetype Webapp

  3. Specify the GroupId and ArtifactId for your web app, and then click Next.

    Specify GroupId and ArtifactId

  4. Customize any Maven settings or accept the defaults, and then click Next.

    Specify Maven settings

  5. Specify your project name and location, and then click Finish.

    Specify project name

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

    Edit index page

Deploying web app to Azure

  1. Under Project Explorer view, right-click your project, expand Azure, then click Deploy to Azure.

    Deploy to Azure menu

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

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

      Deploy to Azure dialog box

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

      Create new web app

    3. 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)

      Deploy to existing webapp

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

    Successful deployment

  4. You can browse to your web app using the link provided in the status message.

    Browsing your web app

Managing deploy configurations

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

    Edit configuration menu

  2. When the Run/Debug Configurations dialog box is displayed, you can modify any of the default settings, and then click OK.

    Edit configuration dialog box

Cleaning up resources

  1. Deleting Web Apps in Azure Explorer

    Clean resources

Next steps

To report bugs or request new features, create issues on our GitHub repository. Or, ask questions on Stack Overflow with tag azure-java-tools.

For more information about using Java with Azure, see the following links:

For additional information about creating Azure Web Apps, see the Web Apps Overview.