Share via

(AuthorizationFailed) Error when trying to update image of containerApp from Azure Devops

Bharath 10 Reputation points
2023-07-19T11:40:47.6333333+00:00

I am using devops pipeline to update a containerApp. The devops pipeline uses a self hosted agent pool which uses a VMSS agent. in the pipeline cli task i create a system assigned managed identity for the containerApp using az cli commands and in the next step i try to assign a registry ACR Pull role to the containerApp on a private ACR using the command below

az role assignment create \
          --assignee-object-id $PRINCIPALID \
          --assignee-principal-type ServicePrincipal \  
          --role AcrPull \
          --scope /subscriptions/$(SUBSCRIPTION)/resourceGroups/$(RG_NAME)/providers/Microsoft.ContainerRegistry/registries/$(acrContainerName) 

getting this error in devops console:

(AuthorizationFailed) The client '3447a78f-2d20-4a27-abcd-4050272e5946' with object id '3447a78f-2d20-4a27-abcd-4050272e5946' does not have authorization or an ABAC condition not fulfilled to perform action 'Microsoft.Authorization/roleAssignments/write' over scope '/subscriptions/12d3e9402-cddbf-4272-83b5-c479199032d6/resourceGroups/my-infra-rg/providers/Microsoft.ContainerRegistry/registries/abccacrxqkglrt4qana4/providers/Microsoft.Authorization/roleAssignments/7722b8ef0-9418-4093-z230-152e422cc29d' or the scope is invalid

I am able to do it through my local command line and also i have user access administrator permission on the subscription. The yaml file task is as follows:

 - task: AzureCLI@2
      inputs:
        azureSubscription: $(armDeploymentServiceConnection)
        scriptType: 'bash'
        scriptLocation: 'inlineScript'

The azureSubscription contains the ARM serviceconnection i created in devops for connecting to ARM. If i search for the client id shown in the devops console error in the azure portal, it does not exist is the result.

Update

When i search for the object id 3447a78f-2d20-4a27-abcd-4050272e5946 i am able to find that in the enterprise applications but it has a different application(client) id than the one showed in the error where both the object id and client id is same.

Enterprise_application_objectid

Can anyone help here? thanks

Can anyone help here? thanks

Can anyone help here? thanks

Azure Container Registry
Azure Container Registry

An Azure service that provides a registry of Docker and Open Container Initiative images.

Azure
Azure

A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.

Microsoft Security | Microsoft Entra | Microsoft Entra ID

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.