This is a guide on how to use Azure DevOps to build and then publish a docker image as an Azure App Service, using Azure Container Registry.

Prerequisites

This guide assumes basic knowledge in Docker and more specifically how to create a Dockerfile. This docker cheat sheet provides a ready Dockerfile with explanations, plus an easy way to create your own Dockerfile from within Visual Studio. The guide also requires an account on Azure and Azure DevOps. The code is hosted in Azure DevOps, but almost any -accessible from Azure DevOps- version control system will do.

In the process that follows, we setup three things mainly; An Azure Container Registry to hold the Docker Image, an Azure DevOps Pipeline to build and push the image to the registry, and and Azure App Service that will continuously pull the image from the registry.

Steps to setup Azure Container Registry

In order to setup an Azure Container Registry, you will of course need to visit portal.azure.com first. After signing in, follow the next three steps to setup and configure Azure Container Registry correctly:

Step 1

Use the convenient search bar on top to search for “Container Registry“. Once the results are in, click on the left side on the “Container Registry” result, as shown here:

Azure Container Registry - Search

Step 2

Once you clicked on the correct result, the “Create Container Registry” form will appear and a few selections have to be made. The minimum changes required here, are to select the Subscription and Resource group you wish (you can also create a new recourse), and to write the Registry name you prefer. Change the Location and SKU if needed and click Create once done.

Azure Container Registry - Create

The Registry name is part of the Login Server for your Azure Container Registry. In this example it will be registryaspnetcoredockerdemo.azurecr.io.

Step 3

Enable the Admin user for this Container Registry. Although the admin account is designed for a single user to access the registry, mainly for testing purposes, in order to be able to use the current registry from an App Service and select image source and Continuous Deployment, the Admin user must be enabled. Find this resource and go to Access Keys to enable the Admin user, as shown below:

Azure Container Registry - Enable Admin User

Read more information about the Admin Account in Microsoft Docs

#azure #docker #azure app service #azure devops #devops

NET Core app using Docker, Azure DevOps, Azure Container Registry
4.15 GEEK