Saturday, 3 September 2022

Manually Push .NET App Docker Image to Azure Container Registry

 You might want to do quick test deploying your containers to AKS or Azure App Services, while development is ongoing. I fyou do not have a pipelines setup yet you may need to manually push your docker  images to Azure Contianer Registry (ACR). Let's have a look at the steps need to push a local image built to ACR using docker commands.

For ecample, consider the following .NET api docker image built and available in a local machine.

Before we push the image to ACR we need to tag it with ACR login server name. You can copy the ACR login server name from the Azure portal, ACR overview page.

Then you can tag the API docker image with the ACR name. as shown below.

docker tag invoiceapi:dev youracrloginservername/mydemo/invoiceapi:1.0

docker tag invoiceapi:dev

Now we can push the image to ACR. It will be added to mydemo/invoiceapi repository in ACR with 1.0 as tag. To push we need to authenticate with the ACR. For this you can copy user name and password from access keys page of ACR in the Azure portal.

The following command can be used to log on to the ACR. For the user name and password you can user a service principal (spn) app id (spn id) and password (spn password), instead of ACR user name and password copied from ACR as shown above. Such service principal in Azure should be assigned with AcrPush role for the ACR

docker login youracrloginservername -u username -p password

Then you can push the image to ACR using the below command.
docker push youracrloginservername/mydemo/invoiceapi:1.0

Once pushed you would be able to see the image is available in ACR.

No comments:

Popular Posts