I was following this guide https://learn.microsoft.com/en-us/azure/devops/repos/git/create-pr-status-server-with-azure-functions?view=azure-devops to create a custom branch policy. The gist of the article is: when an ADO PR is created or updated, the following happens:
Azure functions use Personal Access Token to authenticate with ADO to post a custom status. Two things I don't like about this approach:
So, I wonder if there is a way to use Azure Functions Managed Identity/Service Principal directly in ADO: give ADO permissions to the managed identity and use Azure AD token to authenticate user in ADO API.
I know that you can set up your ADO organization to user Azure AD users. This is how my organization is set up currently:
All "alive" users are shown but I don't see any Managed Identities/Service Principals. It looks like only users are synchronized with ADO.
Unfortunately Azure AD Managed Identity/Service Principal user which uses Client credentials flow are not supported to authenticate to ADO.
You can see that there is no related Authenticate method which you want in this list.
See this answer for more details.