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.
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:
The Azure Toolkit for IntelliJ page at the JetBrains Plugin Repository lists the builds that are compatible with the toolkit.
- A Docker client.
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.
Create a new web app project
Start IntelliJ and sign in to your Azure account using the steps in the Sign In Instructions for the Azure Toolkit for IntelliJ article.
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.
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.
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.
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.
Click the menu icon for + New, then click Containers, and then click Azure Container Registry.
When the information page for the Azure Container Registry template is displayed, click Create.
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.
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.
Deploy your web app in a Docker container
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.
After you have added Docker support, right-click your project in the project explorer, choose Azure, and then click Run on Web App (Linux).
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.
When you have finished configuring the settings listed above, click Run.
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.
When the Run/Debug Configurations dialog box is displayed, you can modify any of the default settings, and then click OK.
For additional resources for Docker, see the official Docker website.
For more information about the Azure Toolkit for IntelliJ IDEA, see the following links:
- Azure Toolkit for IntelliJ
- Release Notes
- Installing the Azure Toolkit for IntelliJ
- Create a Hello World web app for Azure in IntelliJ
- Sign-in instructions for the Azure Toolkit for IntelliJ
For more information about using Java with Azure, see the following links: