Deploy a Hello World web app to a Linux container in the cloud using the Azure Toolkit for IntelliJ

Docker containers are a widely used method for deploying web applications. By using Docker containers, developers can consolidate all their project files and dependencies into a single package for deployment to a server. The Azure Toolkit for IntelliJ simplifies this process for Java developers by adding features for to deploy containers to Microsoft Azure.

This article demonstrates the steps that are required to create a basic Hello World web app and publish your web app in a Linux container to Azure by using the Azure Toolkit for IntelliJ.

Prerequisites

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

  • IntelliJ IDEA Ultimate Edition or Community Edition, which can be downloaded from the JetBrains website.

  • A Java Developer Kit (JDK), version 1.8 or later.

  • An operating system. The Azure Toolkit for IntelliJ has been tested on the following operating systems:

    • Windows 10, Windows 8.1, Windows 8, and Windows 7
    • Windows Server 2012 R2, Windows Server 2012, Windows Server 2008 R2, and Windows Server 2008
    • Mac OS X version "Yosemite" and later
    • Ubuntu Linux version 14, 15, and 16

Note

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

Note

To complete the steps in this tutorial, you need to configure Docker to expose the daemon on port 2375 without TLS. You can configure this setting when installing Docker, or through the Docker settings menu.

Docker settings menu

Create a new web app project

  1. Start IntelliJ and sign in to your Azure account using the steps in the Sign In Instructions for the Azure Toolkit for IntelliJ article.

  2. Click the File menu, then click New, and then click Project.

    Create New Project

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

    Choose Maven archetype webapp

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

    Specify GroupId and ArtifactId

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

    Specify Maven settings

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

    Specify project name

Create an Azure Container Registry to use as a private Docker registry

The following steps walk you through using the Azure portal to create an Azure Container Registry.

Note

If you want to use the Azure CLI instead of the Azure portal, follow the steps in Create a private Docker container registry using the Azure CLI 2.0.

  1. Browse to the Azure portal and sign in.

    Once you have signed in to your account on the Azure portal, you can follow the steps in the Create a private Docker container registry using the Azure portal article, which are paraphrased in the following steps for the sake of expediency.

  2. Click the menu icon for + New, then click Containers, and then click Azure Container Registry.

    Create a new Azure Container Registry

  3. When the information page for the Azure Container Registry template is displayed, click Create.

    Create a new Azure Container Registry

  4. When the Create container registry page is displayed, enter your Registry name and Resource group, choose Enable for the Admin user, and then click Create.

    Configure Azure Container Registry settings

  5. Once your container registry has been created, navigate to your container registry in the Azure portal, and then click Access Keys. Take note of the username and password for the next steps.

    Azure Container Registry access keys

Deploy your web app in a Docker container

  1. Right-click your project in the project explorer, choose Azure, and then click Add Docker Support.

    This will automatically create a Docker file with a default configuration.

    Add Docker support

  2. After you have added Docker support, right-click your project in the project explorer, choose Azure, and then click Run on Web App (Linux).

    Run on Web App (Linux)

  3. When the Run on Web App (Linux) dialog box is displayed, fill in the requisite information:

    • Name: This specifies the friendly name which is displayed in the Azure Toolkit.

    • Server URL: This specifies the URL for your container registry from the previous section of this article; typically this will use the following syntax: "registry.azurecr.io".

    • Username and Password: Specifies the access keys for your container registry from the previous section of this article.

    • Image and tag: Specifies the container image name; typically this will use the following syntax: "registry.azurecr.io/appname:latest", where:

      • registry is your container registry from the previous section of this article
      • appname is the name of your web app
    • Use Existing Web App or Create New Web App: Specifies whether you will deploy your container to an existing web app or create a new web app.

    • Resource Group: Specifies whether you will use an existing or create a new resource group.

    • App Service Plan: Specifies whether you willuse an existing or create a new app service plan.

  4. When you have finished configuring the settings listed above, click Run.

    Create Web App

  5. After you have published your web app, your settings will be saved as the default, and you can run your application on Azure by clicking the green arrow icon on the toolbar. You can modify these settings by clicking the drop-down menu for your web app and click Edit Configurations.

    Edit configuration menu

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

Next steps

For additional resources for Docker, see the official Docker website.

For more information about the Azure Toolkit for IntelliJ IDEA, see the following links:

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