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.

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 this 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

The following steps walk you through the Azure sign in process in your IntelliJ development environment.

  1. If you haven't installed the plugin, see Installing the Azure Toolkit for IntelliJ.

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

    Sign in to Azure on IntelliJ.

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

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

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

  6. Select your Azure account and complete any authentication procedures necessary in order to sign in.

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

  1. Click File, expand New, and then click Project.

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

    Select the maven-archetype-webapp option.

  3. 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.
  4. Customize any Maven settings or accept the defaults, and then click Finish.

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

    Open the index.jsp file.

Deploying web app to Azure

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

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

    Deploy to Azure dialog window.

    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.

  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.

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

    Browsing your web app.

Managing deploy configurations

Tip

After you have published your web app, you can run the deployment by clicking the green arrow icon on the toolbar.

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

    Edit configuration menu.

  2. On the Run/Debug Configurations dialog box, you can modify any of the default settings. Click OK to save the settings.

Cleaning up resources

  1. To delete your web app, navigate to the left-hand Azure Explorer sidebar and locate the Web Apps item.

    Note

    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.

  2. Right-click the web app you'd like to delete and click Delete.

  3. To delete your app service plan or resource group, visit the Azure portal and manually delete the resources under your subscription.

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.