Reputation: 349
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 }
Upvotes: 1
Views: 2244
Reputation: 4776
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.
Refer here for more information
Upvotes: 2