Search code examples
azure-devopsazure-pipelines-release-pipelineazure-rm-templateazure-bicep

Azure Release Pipeline does not have enough permissions to deploy Bicep/ARM template


When I try to deploy my Bicep template through a DevOps release pipeline I get the following error:

Deployment failed with multiple errors: 'Authorization failed for template resource '1525ed81-ad25-486e-99a3-124abd455499' of type 'Microsoft.Authorization/roleDefinitions'. The client '378da07a-d663-4d11-93d0-9c383eadcf45' with object id '378da07a-d663-4d11-93d0-9c383eadcf45' does not have permission to perform action 'Microsoft.Authorization/roleDefinitions/write' at scope '/subscriptions/8449f684-37c6-482b-8b1a-576b999c77ef/resourceGroups/rgabpddt/providers/Microsoft.Authorization/roleDefinitions/1525ed81-ad25-486e-99a3-124abd455499'.:Authorization failed for template resource '31c1daec-7d4a-4255-8528-169fc45fc14d' of type 'Microsoft.Authorization/roleAssignments'.

I understand through this post that I have to grant "something" the Owner or User Access Administrator role.

But I don't understand what user has the ObjectId 378da07a-d663-4d11-93d0-9c383eadcf45.

I tried to look it up with the following az CLI command, but it says that it cannot find a resource with that Id:

az ad user show --id 378da07a-d663-4d11-93d0-9c383eadcf45

The response it returns:

Resource '378da07a-d663-4d11-93d0-9c383eadcf45' does not exist or one of its queried reference-property objects are not present.

I'm a but clueless here. What do I exactly have to grant permission?


Solution

  • When you use service connection in DevOps pipeline, for example Azure Resource Manager service connection, it will create a service principal(app registry) on Azure portal-> Active Directory. You can find the service principal by clicking the link on service connection:

    enter image description here

    When you deploy with service connection, please make sure you have give correct permission for this service principal on target resource, like mentioned Microsoft.Authorization/roleDefinitions/write. Suggest to give contributor role on the resource. Otherwise it will reports the error in your pipeline log.

    When you add the role, you will find the object id, it's different with service principal application ID or object id.

    It's azure role not Azure AD role. You can find the difference in the doc.

    enter image description here