|
| 1 | +# Azure Container Registry (ACR) – Build & Push Guide |
| 2 | + |
| 3 | +This guide provides step-by-step instructions to build and push Docker images for **WebApp** and **Backend** services into Azure Container Registry (ACR). |
| 4 | + |
| 5 | +## 📋 Prerequisites |
| 6 | +Before starting, ensure you have: |
| 7 | +- An active [Azure Subscription](https://portal.azure.com/) |
| 8 | +- [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) installed and logged in |
| 9 | +- [Docker Desktop](https://docs.docker.com/get-docker/) installed and running |
| 10 | +- Access to your Azure Container Registry (ACR) |
| 11 | +- To create an Azure Container Registry (ACR), you can refer to the following guides: |
| 12 | + |
| 13 | + - [Create Container Registry using Azure CLI](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-azure-cli) |
| 14 | + |
| 15 | + - [Create Container Registry using Azure Portal](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-portal?tabs=azure-cli) |
| 16 | + |
| 17 | + - [Create Container Registry using PowerShell](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-powershell) |
| 18 | + |
| 19 | + - [Create Container Registry using ARM Template](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-geo-replication-template) |
| 20 | + |
| 21 | + - [Create Container Registry using Bicep](https://learn.microsoft.com/en-us/azure/container-registry/container-registry-get-started-bicep?tabs=CLI) |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +Login to ACR : |
| 26 | +``` bash |
| 27 | +az acr login --name $ACR_NAME |
| 28 | +``` |
| 29 | + |
| 30 | +## 🚀 Build and Push Images |
| 31 | + |
| 32 | +**Backend :** |
| 33 | + |
| 34 | + ```bash |
| 35 | +az acr login --name <containerregname> |
| 36 | +docker build --no-cache -f docker/Backend.Dockerfile -t <acrloginserver>/<repo>:<tagname> . |
| 37 | +docker push <acrloginserver>/<repo>:<tagname> |
| 38 | + ``` |
| 39 | + |
| 40 | + If you want to update image tag and image manually you can follow below steps: |
| 41 | +- Go to your **Container App** in the [Azure Portal](https://portal.azure.com/#home). |
| 42 | +- In the left menu, select **Containers**. |
| 43 | +- Under your container, update: |
| 44 | + |
| 45 | + - Image source → Azure Container Registry / Docker Hub. |
| 46 | + |
| 47 | + - Image name → myapp/backend. |
| 48 | + |
| 49 | + - Tag → change to the new one you pushed (e.g., v2). |
| 50 | + |
| 51 | +- Click **Save** → this will create a new revision automatically with the updated image. |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +**WebApp :** |
| 56 | + |
| 57 | +```bash |
| 58 | +az acr login --name <containerregname> |
| 59 | +docker build --no-cache -f docker/Frontend.Dockerfile -t <acrloginserver>/<repo>:<tagname> . |
| 60 | +docker push <acrloginserver>/<repo>:<tagname> |
| 61 | +``` |
| 62 | + |
| 63 | +If you want to update image tag and image manually you can follow below steps: |
| 64 | +- Go to your App Service in the [Azure Portal](https://portal.azure.com/#home). |
| 65 | +- In the left menu, select Deployment → Deployment Center |
| 66 | +- Under Container settings, you can configure: |
| 67 | + |
| 68 | + - Image Source → (e.g., Azure Container Registry / Docker Hub / Other). |
| 69 | + |
| 70 | + - Image Name → e.g., myapp/backend. |
| 71 | + |
| 72 | + - Tag → e.g., v1.2.3. |
| 73 | + |
| 74 | + |
| 75 | + |
| 76 | + |
| 77 | +## ✅ Verification |
| 78 | + |
| 79 | +Run the following command to verify that images were pushed successfully: |
| 80 | +```bash |
| 81 | +az acr repository list --name $ACR_NAME --output table |
| 82 | +``` |
| 83 | + |
| 84 | +You should see repositories in the output. |
| 85 | + |
| 86 | +## 📝 Notes |
| 87 | + |
| 88 | +- Always use meaningful tags (v1.0.0, staging, prod) instead of just latest. |
| 89 | + |
| 90 | +- If you are pushing from a CI/CD pipeline, make sure the pipeline agent has access to Docker and ACR. |
| 91 | + |
| 92 | +- For private images, ensure your services (e.g., Azure Container Apps, AKS, App Service) are configured with appropriate ACR pull permissions. |
| 93 | + |
| 94 | + |
| 95 | + |
0 commit comments