Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (2024)

Learn how to host images on Azure Container Registry and deploy a Web App via the App Service plan. A step-by-step guide by Suzaril Shah

Welcome to my latest blog post! I'm Suzaril Shah, a Gold Microsoft Learn Student Ambassador, and today I'm excited to share a detailed, step-by-step guide on how to efficiently host your images on Azure Container Registry (ACR) and deploy a web application using an App Service plan. Whether you're a developer, IT professional, or just a tech enthusiast looking to expand your Azure knowledge, this guide is designed to walk you through the process seamlessly. From setting up your ACR to deploying your app, I'll cover all the necessary steps and best practices to ensure you can get your web app up and running with ease. Let's dive in and start deploying on Azure!

Prerequisites:

  • Azure CLI
    • Steps to install Azure CLI
  • Azure subscription
    • If you don’t already have one, you can sign up for anAzure free account.
    • For Students, you can use the freeAzure for Students offerwhich doesn’t require a credit card only your school email.

Step 1 - Prepare the Docker Container

For this demonstration, I cloned this Docker Hub Image and tagged the image to my own Docker Hub account. This image particularly contains web pages, which is useful to display that the web app is served and accessible via the internet. However, if you have your own Docker image, feel free to use them.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (1)

Step 2 - Setting the Container Registry on Azure

Go to Azure Portal (portal.azure.com) and search for “Container Registries” on the Search bar and click on it. Create a new registry by clicking on the “+ Create” button.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (2)

Select your Subscription and Resource Group from the dropdown and name your registry.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (3)

Click on “Next >” button until you have reached the “Review + create”. Click on “Create” button to finalize the registry creation.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (4)

Once the Deployment is complete, click on the “Go to resource” button to view the registry. At this point the registry is ready to store the image in the registry.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (5)

Enable Admin user on the Azure Container Registry

Each container registry includes an admin user account, which is disabled by default. You can enable the admin user and manage its credentials in the Azure portal, or by using the Azure CLI, Azure PowerShell, or other Azure tools. The admin account has full permissions to the registry.

To enable Admin user, you can go to the container registry page you have created earlier and head to “Settings” > “Access Keys” subsection. Click on the checkbox for “Admin User”. Two passwords should be generated.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (6)

Step 3 - Push image to Azure container registry from Docker Hub

On the Azure Container Registry page, click on the “Push an Image” button to get started with the hosting the image on Azure registry.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (7)

Follow the instructions given on Azure to login, pull & tag image to ACR and push the image to the Azure registry.


Login to Azure on a CLI.

az login

Upon logging in to Azure via CLI, you should be redirected to complete browser authentication and see this page:

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (8)

Now login to your Azure Container registry

az acr login --name [REGISTRY_NAME]

You should receive an output resembling the following:

az acr login --name suzarilshahLogin Succeeded

Pull the image on Docker Hub and tag the image to ACR.

Now pull an image to your host machine so we can prepare and host them on Azure Container Registry. In this case, I will use the image in Step 1.

docker pull airilshahz/apptestUsing default tag: latestlatest: Pulling from airilshahz/apptest59bf1c3509f3: Pull complete683dd8c3cc08: Pull completeae5b2724f19b: Pull complete39190df3f477: Pull completedd3448b85aa1: Pull completed73408ac8b5c: Pull complete26a6466d7ac5: Pull complete3db399cf7250: Pull completeDigest: sha256:249cb92c030c02d5a13b1beef894c306e77aa82e6847e7fc04d2ec46f8306579Status: Downloaded newer image for airilshahz/apptest:latestdocker.io/airilshahz/apptest:latestWhat's Next? View a summary of image vulnerabilities and recommendations → docker scout quickview airilshahz/apptest

Let’s tag the image following the tag format: [REGISTRY_ENDPOINT/REPOSITORY/IMAGE]. You can find the Registry Endpoint at the ACR Overview page (Login server)

docker tag airilshahz/apptest suzarilshah.azurecr.io/webapp/apptest

Push the Image on Azure Container Registry

docker push suzarilshah.azurecr.io/webapp/apptestUsing default tag: latestThe push refers to repository [suzarilshah.azurecr.io/webapp/apptest]177b596a6349: Pushed9707d450e65b: Pushed5bcf0d6dff6a: Pushed1b6b342bd971: Pushed49281578ca1a: Pushedc833154f20e9: Pushed5be440dc5019: Pushed8d3ac3489996: Pushedlatest: digest: sha256:249cb92c030c02d5a13b1beef894c306e77aa82e6847e7fc04d2ec46f8306579 size: 1998

Now you have an image stored on Azure Container Registry. You can check the image you pushed on ACR by going to the “Services” > “Repositories” section on the ACR page.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (9)

Step 4 - Deploy the Image to App Service from ACR

Head to “App Service” by searching for them on the Search bar on Azure portal. Click on the “+ Create” > “Web App” button to create a Web App.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (10)

Select Subscription from the drop down menu and specify the resource group. Then, name your web app endpoint. Follow the configuration as specified below. Please ensure that you have selected “Container” for the “Publish” configuration.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (11)

Create a new Linux Plan under the “Pricing plans” section. For this demonstration, I will use the Free tier to host my web app. Then, click on Next to proceed with creating the web app.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (12)

On the “Container” tab, make sure to Select “Azure Container Registry” as the Image Source. Select the Registry you have created earlier and specify the Image and Tag.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (13)

On the “Networking” tab, please make sure to turn on the “Enable public access” settings. This ensures that our web app is accessible to everyone on the Internet. Turn this off, if you do not intend to allow external users to access your web app.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (14)

Click on the “Review + create” button to finalize the Web App configuration. Click on “Create” button to deploy the web app.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (15)

After the Web App is deployed successfully, click on the “Go to resource” button to view the Web App overview page.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (16)

To view your Web App, click on the “Browse” button on the Web App overview page or copy and paste the information from the “Default domain” section to access your web app.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (17)

Voila! The Web App is now accessible on the Internet.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (18)

Learning takeaways

This comprehensive guide provides a detailed walkthrough on using Azure Container Registry (ACR) and Azure App Service to host and deploy web applications. Readers should be able to set up ACR, host images to ACR, and deploy the images hosted on ACR via App Service. This tutorial not only enhances technical skills in managing cloud-based applications but also offers practical insights into integrating and leveraging Azure services to publish applications on the internet.

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide (2024)

FAQs

Host and Deploy Images on Azure Container Registries (ACR) via App Service - A step-by-step guide? ›

Build and publish to Azure Container Registry

Select your repository, and then select Starter pipeline. Once the pipeline run is complete, you can verify your image in Azure. Navigate to your Azure Container Registry in Azure portal, and then select Repositories.

How to deploy Docker image on Azure App Service? ›

Deploy the image to Azure
  1. In Docker Explorer, navigate to your image under Registries, right-click on the tag, and select Deploy Image To Azure App Service... or Deploy Image to Azure Container Apps....
  2. When prompted, provide the values for the App Service or Container App.

How to publish a container image to Azure container Registry? ›

Build and publish to Azure Container Registry

Select your repository, and then select Starter pipeline. Once the pipeline run is complete, you can verify your image in Azure. Navigate to your Azure Container Registry in Azure portal, and then select Repositories.

How to deploy Docker image in acr to aks? ›

Deploy the sample image from ACR to AKS
  1. Ensure you have the proper AKS credentials using the az aks get-credentials command. Azure CLI Copy. ...
  2. Create a file called acr-nginx. ...
  3. Run the deployment in your AKS cluster using the kubectl apply command. ...
  4. Monitor the deployment using the kubectl get pods command.
Jul 14, 2023

How to deploy container app in Azure? ›

Build and deploy the container app
  1. Create the resource group.
  2. Create an Azure Container Registry.
  3. Build the container image and push it to the registry.
  4. Create the Container Apps environment with a Log Analytics workspace.
  5. Create and deploy the container app using the built container image.
May 6, 2024

How to deploy Docker image to container? ›

How to Perform Docker Deployment of an Application With Docker Containers?
  1. Install Docker on the machines you want to use it;
  2. Set up a registry at Docker Hub;
  3. Initiate Docker build to create your Docker Image;
  4. Set up your 'Dockerized' machines;
  5. Deploy your built docker image or application.

How do I deploy a custom image in Azure? ›

To create a custom image using the Azure portal:
  1. Sign in to the Azure portal.
  2. In the search bar, enter Azure Virtual Desktop and select the matching service entry.
  3. Select Custom image templates, then select +Add custom image template.
  4. On the Basics tab, complete the following information:
Jan 24, 2024

How to push an image to a Kubernetes registry? ›

Push Images To Private Registry In Kubernetes Cluster
  1. Log in to the Docker registry by using the previously created credentials. ...
  2. Pull the nginx:latest Docker image: ...
  3. Tag the image with a custom name and prepend the private Docker registry domain name. ...
  4. Push the Docker Image to the registry.
Jan 13, 2023

How do I deploy Docker image using Azure Devops? ›

From the Configure tab, select the Docker - Build and push an image to Azure Container Registry task. Select your Azure Subscription, and then select Continue. Select your Container registry from the dropdown menu, and then provide an Image Name to your container image. Select Validate and configure when you are done.

How to deploy a Docker image using helm? ›

Procedure
  1. Tag the 3 images (API node, backend, and Streams) with a 2.0.3 tag by running the following commands: docker tag <ftr image name> :1.0.3 <ftr image name> :2.0.3. ...
  2. Use the following commands to purge the cats-policy release: helm ls. ...
  3. Run the following command to deploy Helm: ...
  4. Initialize the volume for Streams:

How do I deploy files to Azure App Service? ›

The CLI command uses the Kudu publish API to deploy the files and can be fully customized.
  1. Deploy a startup script. Azure CLI Copy. az webapp deploy --resource-group <group-name> --name <app-name> --src-path scripts/startup.sh --type=startup.
  2. Deploy a library file. Azure CLI Copy. ...
  3. Deploy a static file. Azure CLI Copy.
May 31, 2024

How to check images in Azure container Registry? ›

Azure Credentials for details.
  1. Log in to Console, and select Defend > Vulnerabilities > Images > Registry settings.
  2. Add registry.
  3. In Add New Registry, enter the following values: In Version, select Azure Container Registry. ...
  4. Select Add and scan.
Apr 28, 2024

Does Azure App Service support containers? ›

Deploy to Azure in seconds

It has never been easier to deploy container-based web apps. Just pull container images from Docker Hub or a private Azure Container Registry, and Web App for Containers will deploy the containerized app with your preferred dependencies to production in seconds.

How do I deploy Docker image using Azure DevOps? ›

From the Configure tab, select the Docker - Build and push an image to Azure Container Registry task. Select your Azure Subscription, and then select Continue. Select your Container registry from the dropdown menu, and then provide an Image Name to your container image. Select Validate and configure when you are done.

How to create a Docker image on Azure? ›

To create a container instance with the Azure CLI, provide a resource group name, container instance name, and Docker container image to the az container create command. In this quickstart, you use the public mcr.microsoft.com/azuredocs/aci-helloworld image. This image packages a small web app written in Node.

How to setup Docker in Azure VM? ›

Get Started with Docker and Compose to define and run a multi-container application on an Azure virtual machine
  1. Step 1: Set up a Linux VM as a Docker host. ...
  2. Step 2: Install Compose. ...
  3. Step 3: Create a docker-compose. ...
  4. Step 4: Start the containers with Compose.

References

Top Articles
Latest Posts
Article information

Author: Zonia Mosciski DO

Last Updated:

Views: 6324

Rating: 4 / 5 (51 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Zonia Mosciski DO

Birthday: 1996-05-16

Address: Suite 228 919 Deana Ford, Lake Meridithberg, NE 60017-4257

Phone: +2613987384138

Job: Chief Retail Officer

Hobby: Tai chi, Dowsing, Poi, Letterboxing, Watching movies, Video gaming, Singing

Introduction: My name is Zonia Mosciski DO, I am a enchanting, joyous, lovely, successful, hilarious, tender, outstanding person who loves writing and wants to share my knowledge and understanding with you.