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 }