Streamlining Continuous Deployment: Using Azure Container Registry to Automate Web App Updates
Forget complex deployment pipelines—learn how leveraging Azure Container Registry's native integration with Web Apps can simplify and speed up your container deployment process without compromising control or security.
In today’s fast-paced digital world, deploying updates quickly and reliably is critical to staying competitive. When you’re working with containerized web applications, managing the deployment workflow efficiently can be the difference between a smooth release and a stressful scramble. This post walks you through how to automate continuous deployment of your containerized apps using Azure Container Registry (ACR) and Azure Web Apps, giving you a streamlined, robust, and secure way to keep your applications up-to-date.
Why Use Azure Container Registry with Azure Web Apps?
- Seamless Integration: Azure Web Apps for Containers supports pulling images directly from ACR without the need for complex custom scripts.
- Faster Deployment Cycles: Automated updates mean quicker push-to-prod cycles.
- Version Control & Rollback: Tag images appropriately in ACR to manage app versions easily.
- Security First: ACR supports private repositories with role-based access control and integration with Azure Active Directory.
Step-by-Step Guide to Setting Up Continuous Deployment
We’ll cover how to:
- Build and push your container image to ACR
- Configure Azure Web App to use images from ACR
- Set up automated deployments so that updates in ACR trigger app refreshes
Prerequisites:
- Azure CLI installed
- Docker installed locally
- An active Azure subscription
Step 1: Create an Azure Container Registry
If you don’t have an ACR instance yet, create one:
az acr create --resource-group myResourceGroup --name myUniqueACRName --sku Basic
Replace myResourceGroup
and myUniqueACRName
with your preferred names.
Step 2: Build and Push Your Docker Image
Assuming you have a simple web app Dockerfile ready in your project directory:
# Log in to your ACR instance
az acr login --name myUniqueACRName
# Tag your local image with the login server address for ACR
docker build -t mywebapp:latest .
docker tag mywebapp:latest myuniqueacrname.azurecr.io/mywebapp:latest
# Push the image to ACR
docker push myuniqueacrname.azurecr.io/mywebapp:latest
Step 3: Create an Azure Web App for Containers
Create a Linux-based App Service plan & web app:
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku B1 --is-linux
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name myWebAppName --deployment-container-image-name myuniqueacrname.azurecr.io/mywebapp:latest
Step 4: Configure Web App To Use Private ACR Repository
Grant the web app access to pull from the private registry:
az webapp config container set \
--resource-group myResourceGroup \
--name myWebAppName \
--docker-registry-server-url https://myuniqueacrname.azurecr.io \
--docker-registry-server-user <username> \
--docker-registry-server-password <password>
Alternatively, use Managed Identity with role assignment for enhanced security:
# Assign AcrPull role to the web app's managed identity on the registry
WEBAPP_ID=$(az webapp show -n myWebAppName -g myResourceGroup --query identity.principalId -o tsv)
REGISTRY_ID=$(az acr show -n myUniqueACRName -g myResourceGroup --query id -o tsv)
az role assignment create --assignee $WEBAPP_ID \
--role acrpull \
--scope $REGISTRY_ID
# Enable system-assigned managed identity on the web app (if not already enabled)
az webapp identity assign -g myResourceGroup -n myWebAppName
# Set the container config without specifying username/password now:
az webapp config container set \
-g myResourceGroup \
-n myWebAppName \
-i myuniqueacrname.azurecr.io/mywebapp:latest \
-r https://myuniqueacrname.azurecr.io
Step 5: Enable Continuous Deployment from ACR
Unlike GitHub or Bitbucket source repositories, setting up continuous deployment directly from ACR involves configuring Webhooks or leveraging deployment slots & Azure DevOps pipelines. Here’s a simple approach using webhooks:
- Create a webhook in ACR that triggers on image push.
- The webhook can call an Azure Function or Logic App that restarts the Web App — forcing it to pull the new image.
Create a webhook triggering on pushes:
az acr webhook create \
--registry myUniqueACRName \
--name MyWebhookForWebApp \
--uri "https://<your-function-app>.azurewebsites.net/api/RestartWebApp" \
--actions push
Then, build an Azure Function that restarts the Web App using Azure REST API or CLI commands via Microsoft Graph SDK or SDKs in your language of choice.
Alternatively, if you use Azure DevOps Pipelines, configure your CI pipeline to build/push docker images to ACR, then invoke deployment tasks updating your Web App accordingly.
Bonus Tips for Better Management
- Use descriptive tags like
v1.0
,v1.1
, etc., rather than justlatest
so you can roll back if needed. - For high availability, enable deployment slots on your Web App — stage updates before swapping production.
- Integrate monitoring and alerting (Azure Monitor) for build failures or deployment issues.
Summary
By following this approach, you utilize native integrations between Azure Container Registry and Azure Web Apps, drastically simplifying continuous deployment of containerized applications. It removes layers of complexity often imposed by external orchestrators or scripts while maintaining security through managed identities.
This workflow means more frequent, reliable deployments without manual overhead—keeping your team agile and ensuring your users get new features faster.
If you found this tutorial helpful or want me to dive deeper into any part like setting up automated pipelines with GitHub Actions for this flow, let me know in the comments!
Happy deploying! 🚀
Tags: #Azure #Containers #ContinuousDeployment #DevOps #WebApps #AzureContainerRegistry