Member-only story
#101 Azure DevOps + Azure Container Registry (part 2/3): Connect ACR and Azure DevOps repository
In the previous part (part 1), we have learnt how to push docker image from local machine to image repo on Azure Container Registry (ACR) using Azure CLI and Docker CLI. However, we have not yet linked these 2 services: Azure DevOps and ACR together, which is exactly the theme for this part 2. In this blog post, you will learn how to build and push docker image with Pipeline from Azure DevOps. If you happen not yet to check part 1, I highly recommend you to spend some time skimming through part 1 to fully grasp the context of this part.
Why we need to build and push image from Azure DevOps?
With the approach of pushing Docker image from local machine to ACR in part 1, we can clearly see that this is a one-side ticket. Whatever image we push to ACR, it will stay exactly as it is. There will be no automatic image update or any version update of that image to be found in ACR. Whenever we make code changes, these changes won't be updated automatically to ACR. This actually goes against the CI/CD principles. If you are not yet familiar with CI/CD basics, please visit this blog post.
The good news is that you can fix this situation by building and pushing the image from Azure DevOps. This approach will allow the automatic image update on ACR. And this is how Azure DevOps and Azure Container Registry is linked together.
Build and push Docker image from Azure DevOps
Let's get right into step-by-step instruction on how to build and push Docker image to image repository on Azure Container Registry.
- You DON’T need to create a new image repository on ACR beforehand. You can define it later. Instead, upload your code base to Azure DevOps repo with git command. I'm pretty sure that you can do it!
- Then the next step is to direct to the Azure DevOps repository that you just uploaded the code onto. Then choose “Pipelines".
3. Choose “New pipeline".