Build and Push Image to ACR with Azure DevOps

Azure Pipelines is a DevOps service in Azure that enables you to create a continuous integration and deployment pipeline for your applications. You can use Azure Pipelines to automatically build, test, and deploy your code changes by integrating with popular development tools such as GitHub and Visual Studio.

This post will show how to use Azure DevOps pipelines to build and push a Docker image to Azure Container Registry.

In addition to supporting your development process, Azure Pipelines can also help you manage your releases. You can use Azure Pipelines to create a release pipeline that automates the release process for your application. This includes tasks such as promoting an application from staging to production or deploying an application to multiple environments.

Create Pipeline

We need to build and push an image to ACR to create a pipeline from the Pipelines side menu shown below.

Click on Create Pipeline

To build a Docker image to point the pipeline to the repository that has the Dockerfile, Azure DevOps has a few options. In my case, I’m using Azure Repos git. If you’re using GitHub or something else, select it and follow the prompts.

The connection process is straightforward regardless of whether you are using Azure Repos or GitHub.

After configuring the connection to the repo, please select it and move to the following menu.

In the Configure your pipeline page, Click on Docker (Build and push and image to ACR)

After selecting the option, we need to select the Azure subscription our ACR is located.

The ACR registry will appear under the drop-down of the Container registry. We also have an option to name the image.

To start the build and push operation, Click on Save and run.

Azure creates a commit directly to the master branch to trigger a build.

After committing the code, Azure DevOps will run a job to build and push the image.

You can track every build step from the job page, as shown below.

After the job has been completed, you will see the image in ACR.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.