When it comes to DevOps Docker is an integral part of it. Nowadays no development can be done without the help of docker. In this article, we will discuss how can we use Azure DevOps Pipeline to build and push images to the Azure container registry. Here is the end-to-end Video of this post. I have created a solution that shows an end-to-end demo of this concept.

https://www.youtube.com/watch?v=PJgh0orq0Js&t=4s

What is Azure Container Registry?

Azure Container Registry is a private registry for hosting container images. Using the Azure Container Registry, you can store Docker-formatted images for all types of container deployments. Azure Container Registry integrates very well with orchestrators hosted in Azure Container Service, including Docker Swarm, DC/OS, and Kubernetes. You can use the familiar tooling capable of working with the open-source Docker Registry v2 so it is a seamless experience for Docker hub users.

Here are the features of the Azure container registry:

What is DevOps Pipeline?

DevOps pipeline is used for implementing CI/CD process to automate building, testing, and deployment of code.

What is Azure Pipeline?

Azure Pipelines is a cloud service that you can use to automatically build and test your code and make it available to other users.

Features of Azure Pipeline.

Solution Overview

In this solution, we will create an Azure container registry and then build a Docker image from the Github code repo to push the image into the Azure container registry. This is a typical solution used for any DevOps Pipeline.

First, we will clone the code from the existing sample Github Repo and then create an Azure resource group and container registry. Here is the code:

git clone https://github.com/MicrosoftDocs/pipelines-javascript-docker
az login
#I have used Powershell ISE to run Azure CLI code
#but if you want to use Azure CLI then change these variables
#accordingly by removing $
$rg="demo-rg"
$acrname="myacr07"
$loc="eastus"
# Create a resource group
az group create --name $rg --location $loc

# Create a container registry
az acr create --resource-group $rg --name $acrname --sku Basic

Then I created Azure Pipeline and here are step-by-step instructions:

  1. Go to Your Azure DevOps Org

2. Select Pipeline to create the pipeline.

3. Create a new Pipeline.

4. Select your code organization.

5. Select GitHub Repo.

6. Configure the pipeline.

7. Select the image configurations.

8. Review Image config. Actually when you selected the “Build and push the image into Docker registry” option while configuring the pipeline Azure creates this template which has a built-in Task to build and push the docker image into Azure Container Registry.

9. Test if the container image is pushed into the Azure Container registry or not? We can see that the Image is pushed successfully.

I hope you enjoyed it.

Leave a Reply

Your email address will not be published. Required fields are marked *