Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Servers, nginx and Docker

Azure App Service fails to pull a custom container image from ACR

Your error

Head "https://<acr-name>.azurecr.io/v2/<repository>/manifests/<tag>": unauthorized3 more lines it can show

Fix it fast

Most common cause, 1 of 4

The registry user name or password in the app settings is wrong

Write the current registry credentials into the container configuration, or better, switch the app to a managed identity so no password needs to be kept in sync.

Fix
az webapp config container set --name my-app --resource-group my-rg \
  --container-image-name myregistry.azurecr.io/shop-api:1.4.2 \
  --docker-registry-server-url https://myregistry.azurecr.io \
  --docker-registry-server-user <username> \
  --docker-registry-server-password <password>
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

When Azure App Service cannot pull a custom container from Azure Container Registry, the Deployment Center log names the cause. unauthorized means wrong registry credentials or a managed identity without pull rights, manifest unknown means the tag does not exist, and client with IP is not allowed means the registry firewall blocks the app. Fix that one and restart.

  • Applies to Azure App Service (Linux and Windows custom containers), Azure Container Registry, Azure CLI 2.93
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Turn on container logging and stream the log while the app restarts. The pull line after the timestamp names the cause. In the portal the same text is under Deployment Center, Log, or Log stream.

Run this first
az webapp log config --name my-app --resource-group my-rg --docker-container-logging filesystem
az webapp log tail --name my-app --resource-group my-rg

Then find the line you see in this list and open its fix:

  1. 1The registry user name or password in the app settings is wrongThe pull fails with unauthorized, and the app uses DOCKER_REGISTRY_SERVER_URL, DOCKER_REGISTRY_SERVER_USERNAME and DOCKER_REGISTRY_SERVER_PASSWORD
  2. 2The managed identity has no pull permission, or the app is not told to use itunauthorized while no registry password is set, or UNAUTHORIZED with token validation failed
  3. 3The tag the app asks for was never pushedDockerApiException with status code=NotFound and manifest tagged by "<tag>" is not found
  4. 4The registry firewall does not allow the app's outbound addressesdenied: client with IP '<web-app-outbound-ip>' is not allowed access

What does the error look like?

  • Head "https://<acr-name>.azurecr.io/v2/<repository>/manifests/<tag>": unauthorized
  • manifest unknown: manifest tagged by "<tag>" is not found
  • denied: client with IP '<web-app-outbound-ip>' is not allowed access. Refer https://aka.ms/acr/firewall to grant access.
  • token validation failed

Cause 1 of 4

The registry user name or password in the app settings is wrong

You seeThe pull fails with unauthorized, and the app uses DOCKER_REGISTRY_SERVER_URL, DOCKER_REGISTRY_SERVER_USERNAME and DOCKER_REGISTRY_SERVER_PASSWORD

Check

App Service reports unauthorized when the sign-in server, user name or password it holds for the registry does not match the registry's admin credentials. A rotated admin password or a value copied from another registry is enough to cause it. Compare the URL and user name the app holds with the sign-in server and user name on the registry's Access keys page, and re-enter the password if in doubt.

Check
az webapp config appsettings list --name my-app --resource-group my-rg \
  --query "[?name=='DOCKER_REGISTRY_SERVER_URL' || name=='DOCKER_REGISTRY_SERVER_USERNAME'].[name,value]" --output table

Fix

Write the current registry credentials into the container configuration, or better, switch the app to a managed identity so no password needs to be kept in sync.

Fix
az webapp config container set --name my-app --resource-group my-rg \
  --container-image-name myregistry.azurecr.io/shop-api:1.4.2 \
  --docker-registry-server-url https://myregistry.azurecr.io \
  --docker-registry-server-user <username> \
  --docker-registry-server-password <password>

Verify

After the restart the log stream shows the image pull finishing and the container starting.

Verify
az webapp log tail --name my-app --resource-group my-rg

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 4

The managed identity has no pull permission, or the app is not told to use it

You seeunauthorized while no registry password is set, or UNAUTHORIZED with token validation failed

Check

Pulling with a managed identity needs four things: the identity turned on, a role with registries/pull/read (such as AcrPull) on the registry, acrUseManagedIdentityCreds set to true, and a registry that accepts ARM audience tokens. A deleted role assignment, or an Azure Policy that blocked it, leaves the identity without access; ARM tokens switched off gives token validation failed. A user-assigned identity also needs acrUserManagedIdentityID.

Check
az webapp identity show --name my-app --resource-group my-rg --query principalId --output tsv
az role assignment list --assignee <principal-id> --scope <registry-resource-id> --query "[].roleDefinitionName"
az acr config authentication-as-arm show -r myregistry

Fix

Give the identity AcrPull on the registry, point the app at its managed identity, and enable ARM audience tokens on the registry if they are off.

Fix
az role assignment create --assignee <principal-id> --scope <registry-resource-id> --role "AcrPull"
az webapp config set --resource-group my-rg --name my-app --generic-configurations '{"acrUseManagedIdentityCreds": true}'
az acr config authentication-as-arm update -r myregistry --status enabled

Verify

The role list now shows AcrPull, and the next restart pulls the image.

Verify
az role assignment list --assignee <principal-id> --scope <registry-resource-id> --query "[].roleDefinitionName"

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 4

The tag the app asks for was never pushed

You seeDockerApiException with status code=NotFound and manifest tagged by "<tag>" is not found

Check

This error means credentials and network worked, but the repository has no image under that tag. A pipeline that pushes a new build number while the app still points at an older or mistyped tag ends here.

Check
az acr repository show-tags -n myregistry --repository shop-api --output table

Fix

Point the app at a tag that exists, or push the missing tag, then restart the app.

Fix
az webapp config container set --name my-app --resource-group my-rg \
  --container-image-name myregistry.azurecr.io/shop-api:1.4.2
az webapp restart --name my-app --resource-group my-rg

Verify

show-tags lists the tag the app uses, and the log no longer reports manifest unknown.

Verify
az acr repository show-tags -n myregistry --repository shop-api --output table

Confirmed by learn.microsoft.com

Did this fix it?

Cause 4 of 4

The registry firewall does not allow the app's outbound addresses

You seedenied: client with IP '<web-app-outbound-ip>' is not allowed access

Check

An Azure container registry accepts connections from every network until someone limits it to selected networks or turns public access off. After that, the App Service pull comes from the app's outbound IP addresses, which the IP rules must include, unless the pull runs privately over a virtual network. The registry's Networking page in the portal shows whether public access is limited. On the Premium V4 tier the app has no stable outbound addresses and the CLI returns empty values, so only the private path fits there.

Check
az webapp show --name my-app --resource-group my-rg --query possibleOutboundIpAddresses --output tsv

Fix

Add each outbound address of the app as a network rule (IP rules need the Premium tier), or keep the registry private: give it a private endpoint, add virtual network integration to the app with Container image pull selected, and route the pull through the network.

Fix
az acr network-rule add --name myregistry --ip-address 203.0.113.25
# private path instead of IP rules
az resource update --resource-group my-rg --name my-app \
  --resource-type "Microsoft.Web/sites" --set properties.vnetImagePullEnabled=true

Verify

Wait a few minutes for the rule to apply, restart the app and watch the pull succeed in the log stream.

Verify
az webapp restart --name my-app --resource-group my-rg && az webapp log tail --name my-app --resource-group my-rg

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Pull with a managed identity that holds AcrPull, as Microsoft recommends, instead of the registry admin password, so a password rotation cannot break the next restart.
  • Have the deploy pipeline set the app's image tag in the same job that pushes it, so the app never points at a tag that does not exist.
  • Before you restrict the registry network, add the app's outbound addresses or its private endpoint path, and run az acr check-health afterwards.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: Raheeb.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.