azureazure-devopsazure-pipelinesazure-container-registry

Azure Container Apps: Azure Container Registry Authentication Issue


I've been trying to deploy a docker image that's already pushed in our azure container registry. I'm receiving the following error:

/usr/bin/az containerapp update -n <appName> -g <resourceGroupName> -i <containerRegistry>.azurecr.io/<repository>:20240430.13 --replace-env-vars ASPNETCORE_ENVIRONMENT=Acceptance
ERROR: (InvalidParameterValueInContainerTemplate) The following field(s) are either invalid or missing. Field 'template.containers.<appName>.image' is invalid with details: 'Invalid value: "<containerRegistry>.azurecr.io/<repository>:20240430.13": GET https:?scope=repository%3A<containerRegistry>%3Apull&service=<containerRegistry>.azurecr.io: UNAUTHORIZED: authentication required, visit https://aka.ms/acr/authorization for more information.';.
##[error]Error Code: [1]
##[error]Error: Unable to update Azure Container App via 'az containerapp update' command.

As you can see, it gives an error regarding the authentication process to the registry. Here's the job I use for the deployment:

jobs:
- job: Deploy
  displayName: Deploy Docker image
  steps:
    - task: AzureContainerApps@1
      displayName: 'Deploy from container registry'
      inputs:
        resourceGroup: $(resourceGroupName)
        azureSubscription: ${{parameters.devopsServiceConnection}}
        containerAppEnvironment: $(containerAppEnvironment)
        containerAppName: $(appName)
        acrName: $(containerRegistry)
        imageToDeploy: $(containerRegistry).azurecr.io/$(repository):$(Build.BuildNumber)
        environmentVariables: 'ASPNETCORE_ENVIRONMENT=Acceptance'

Here's what I know / have excluded:

I've been messing with this for a few hours now and was hoping someone else had the same issue that could help me solve it.

I've removed a lot of data that are sensitive for my company. But if you see <appName> I've verified that it's the same variable as passed with $(appName).


Solution

  • After being stuck on this for over a week I've finally found an answer, I'd like to share this with everyone. The imageToDeploy is an url, but even though it's an url it's still case sensitive...

    Since the containerRegistry variable had some casing it couldn't "find"?? the Azure container registry, and therefore failed with an authentication error. By lowercasing my acr name for the url it finally worked.