Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Latest commit

 

History

History
90 lines (65 loc) · 3.28 KB

deploy-to-azure-web-app-using-maven-plugin.md

File metadata and controls

90 lines (65 loc) · 3.28 KB

Deploy to Azure Web App for Containers using Maven Plugin

This tutorial shows you how to deploy this containerized app to Azure Web App for Containers using Maven Plugin for Azure Web Apps. Below are the major steps in this tutorial.

Create Azure Container Registry

  1. login your Azure CLI, and set your subscription id

    az login
    az account set -s <your-subscription-id>
  2. Run below command to create an Azure Container Registry. After creation, use login server as Container Registry URL in the next section.

    az acr create -n <your-registry-name> -g <your-resource-group-name> --sku <sku-name>
    where `<sku-name>` is one of the following: `{Basic,Managed_Basic,Managed_Standard,Managed_Premium}`.
    
  3. Run below command to show your Azure Container Registry credentials. You will use Docker registry username and password in the next section.

    az acr credential show -n <your-registry-name>

Setup and Customize Configuration

  1. In the Maven settings file ~/.m2/settings.xml, add a new <server> element with your Azure Container Registry credentials from previous steps.

    <server>
      <id>put-your-docker-registry-url</id>
      <username>put-your-docker-username</username>
      <password>put-your-docker-key</password>
      <configuration>
        <email>put-your-email</email>
      </configuration>
    </server>
  2. In <properties> section of the project's pom.xml, replace value in <docker.image.prefix> element with your Azure Container Registry URL.

    <docker.image.prefix>put-your-docker-registry-url</docker.image.prefix>
  3. Optional. In <properties> section of the project's pom.xml, modify value in <azure.app.name> element with any unique string as your app name.

    Default value is todo-app-${maven.build.timestamp}. The ${maven.build.timestamp} part is used to avoid conflict in Azure and will be different in each build.

Build and Deploy Docker Container Image to Azure Web App for Containers

  1. Verify you can run your project successfully in your local environment. (Run project on local machine)

  2. Build project and docker container image, and push the image to your Azure Container Registry.

    mvn clean package docker:build docker:push
  3. Deploy Docker container image from your Azure Container Registry to Azure Web App for Containers.

    mvn azure-webapp:deploy

    NOTE: You can also run above commands as a one-liner:
    mvn clean package docker:build docker:push azure-webapp:deploy

  4. Navigate to the website from your favorite browser. You will see this app successfully running on Azure Web App for Containers.

Clean Up Resources

Delete the Azure resources you just created by running below command:

az group delete -y --no-wait -n <your-resource-group-name>