Search code examples
azureazure-devopsazure-pipelinesazure-resource-managerazure-managed-identity

Using Managed Identity in Azure Pipelines: GetUserAccessToken: Failed to obtain an access token of identity. AAD returned silent failure


I am trying to run an Azure Resource Group Deployment task in Azure Pipelines. I have deployed an Azure Pipelines self-hosted agent on an Azure VM running Windows, and in my Azure DevOps organization I have set up an Azure Resource Manager service connection to a VM with a managed service identity.

However, I get the following error when trying to configure my Azure Resource Group Deployment task with my service connection with managed identity:

GetUserAccessToken: Failed to obtain an access token of identity . AAD returned silent failure.

Screenshot:

enter image description here

I have already verified that I granted access (Contributor) to the VM's managed identity to the target resource group:

enter image description here

The service connection is also scoped to the Azure subscription:

enter image description here

Any help on diagnosing this issue is appreciated. Thanks!


Solution

  • It appears that the issue comes about because it is the user account authenticated to Azure DevOps that is retrieving subscription information. Azure DevOps is not using the managed identity to retrieve the subscription information.

    In particular, my original Azure DevOps user account had MFA turned on to authenticate to an Azure subscription (e.g. portal.azure.com), but did not have MFA turned on to authenticate to Azure DevOps (e.g. dev.azure.com/). I think that this was causing the issue when failing to get an access token:

    enter image description here

    I created a different user account in my Azure AD, gave it access to my Azure DevOps organization, and made sure that this new user account had Reader permissions over the target subscription and did not have MFA turned on. This resolved the issue of getting subscription info when using managed identity:

    enter image description here