1

I need to use the Azure DevOps Rest API in an Azure DevOps Pipeline. I know it's possible to connect through a PAT token, but there should be a way to use service principal to connect to Azure?

What do I have to change to obtain a bearer token when I run below's code in an Azure DevOps Pipeline?

  Connect-AzAccount -WarningAction 'SilentlyContinue' | Out-Null
  $Token = (Get-AzAccessToken -ResourceUrl "499b84ac-1321-427f-aa17-267ca6975798").Token # Resource url is for Azure DevOps REST API source: https://stackoverflow.com/questions/69996528/authenticate-azure-devops-api-call-without-using-a-pat
  $AzureDevOpsAuthenticationHeader = @{Authorization = 'Bearer ' + $Token }

1 Answer 1

2

As per the MS DOC Currently, it is not possible. Azure DevOps API doesn't support non-interactive service access via service principals.

There is no access control of service principal in Azure DevOps.

Non- interactive ways follows

  • PAT (Most Recommended way)
  • Azure AD ROPC flow (Not recommended because while request we have expose the username and password)

Refer here for more information

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.