Quickstart: Deploy to Azure Container Apps using IntelliJ IDEA

This article shows you how to deploy a containerized application to Azure Container Apps using Azure Toolkit for IntelliJ IDEA. The article uses a sample backend web API service that returns a static collection of music albums.

Prerequisites

Clone the project

Use the following steps to clone and open the sample project:

  1. Use the following commands to clone the sample app and check out the IDE branch:

    git clone https://github.com/Azure-Samples/containerapps-albumapi-java
    cd containerapps-albumapi-java
    git checkout IDE
    
  2. Select Open to open the project in IntelliJ IDEA.

Build and run the project locally

Use the following steps to test the project locally:

  1. Use the following command to build the project with Maven:

    mvn clean package -DskipTests
    
  2. To verify that the application is running, open a browser and go to http://localhost:8080/albums. The page returns a list of JSON objects similar to the output of the following command:

    java -jar target\containerapps-albumapi-java-0.0.1-SNAPSHOT.jar
    

Create an environment

Use the following steps to set up your environment and deploy a container app in Azure:

  1. In the Azure Explorer view, right-click Container Apps Environment and then select Create Container Apps Environment.

  2. On the Create Container Apps Environment page, enter the following information, and then select OK:

    • Subscription: The Azure subscription to use.
    • Resource Group: The resource group for your container apps. Select one of the following options:
      • Create New: Specifies that you want to create a new resource group.
      • Use Existing: Specifies that you must select from a list of resource groups that are associated with your Azure account.
    • Region: The appropriate region, for example, East US.
    • Name: The name for the new Container Apps environment.
    • Type: The type of Container Apps environment. You can accept the default.
    • Workload Profiles: The workload profiles for your container apps. You can accept the default.
    • Log Analytics workspace: The Log Analytics workspace to use. You can accept the default.

    Screenshot of Intelli J that shows the Create Container Apps Environment dialog box.

Deploy the container app

To deploy the container app, use the following steps:

  1. Right-click the Container Apps environment you created, and select Create > Container App in Azure Explorer. Then, enter the following information:

    • Subscription: The Azure subscription to use.
    • Resource Group: The resource group for your container apps. Select one of the following options:
      • Create New: Specifies that you want to create a new resource group.
      • Use Existing: Specifies that you must select from a list of resource groups that are associated with your Azure account.
    • Environment: The Container Apps environment to use.
    • Name: The name for a new container app.
    • Deployment:
      • Source: Select the Source Code option.
      • Code: Select the folder button, and then select the source code folder on your local machine.
    • Container Resource Allocation:
      • Workload Profile: Select the appropriate workload profile based on your application's requirements.
      • CPU and Memory: Allocate the necessary CPU and memory resources for your container app.
    • Ingress Settings:
      • Ingress: Enable or disable ingress based on your application's needs. You can accept the default settings.
      • External Traffic: Specifies whether the container app should accept external traffic. You can accept the default settings.
      • Target Port: Enable or disable ingress based on your application's needs. Configure the target port to 8080.
    • Other:
      • Env Variables: Set any environment variables required by your application.
      • Min Replicas: The minimum number of replicas for your container app. You can accept the default settings.
      • Max Replicas: The maximum number of replicas for your container app. You can accept the default settings.

    Screenshot of Intelli J that shows the Create Azure Container App dialog box.

  2. Select OK. The toolkit displays a status message when the app deployment succeeds.

  3. After the deployment finishes, the Azure Toolkit for IntelliJ displays a notification. Select Browse to open the deployed app in a browser.

    Screenshot of the deployed app in a browser window.

  4. In the browser's address bar, append the /albums path to the end of the app URL to view data from a sample API request.

Clean up resources

To clean up and remove a Container Apps resource, you can delete the resource or resource group. Deleting the resource group also deletes any other resources associated with it. Use the following steps to clean up resources:

  1. To delete your Container Apps resources, from the Azure Explorer sidebar, locate the Container Apps Environment item.
  2. Right-click the Container Apps service you want to delete, and then select Delete.
  3. To delete your resource group, use the Azure portal to manually delete the resources under your subscription.

Next steps