how to resolve this issue "Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name 'appname'. Error: Could not fetch access token for Azure".

Sathish Kumar S (LTIMindtree Limited) 0 Reputation points Microsoft External Staff
2025-04-28T09:19:31.6633333+00:00

am getting this error while setting up my pipeline for my project

Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name 'askprodopsdev'. Error: Could not fetch access token for Azure. Status code: 400, status message: Could not fetch access token for Managed Service Principal. Status code: 400, status message: Bad Request

any idea ??

Azure DevOps
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Divyesh Govaerdhanan 4,830 Reputation points
    2025-04-28T22:19:18.6333333+00:00

    Hello,

    Welcome to Microsoft Q&A,

    This error indicates that your Azure DevOps pipeline or Azure CLI/PowerShell tries to access an Azure resource using Managed Identity, but the identity is not properly set up, or permission issues.

    Assign RBAC Permission to the Identity on the Web App

    • Go to Azure Portal → askprodopsdev (your Web App).

    Go to Access Control (IAM) → Add Role Assignment.

    Assign a role like:

    1. Contributor (broad permission) or if you know the specific actions needed:
    2. Website Contributor (or)
    3. Reader + Custom Role for special needs.

    Select your pipeline's Managed Identity as the principal.

    This will allow the pipeline to get the Resource ID and access it.

    Please Upvote and accept the answer if it helps!!


Your answer

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