This article walks you through setting up the service principal that powers automated CI/CD for Dynamics 365 Finance and Operations using PPAC APIs and Azure DevOps.
By the end of this article, you’ll have a service principal that can manage Power Platform environments and deploy packages – the foundation everything else builds on. For this article, we can think of the SPN as a robot account—this process builds its ID card (app registration), password (secret), and workspace permissions (F&O access). Also, when working with secret, never commit them to source control of any sort. This is a mistake you will make, if you haven’t already, but once its stored in plane text somewhere, you’ll have to rotate the secret to a new value. Additionally, automatic rotation of secrets is highly advised. We won’t have the in our solution, but it’s worth learning more on how to do that.
You now have three values. Keep them secure:
| Value | Where You Got It |
|---|---|
| Tenant ID | App registration > Overview |
| Application (client) ID | App registration > Overview |
| Client Secret | App registration > Certificates & secrets |
This is the step Microsoft doesn’t make obvious. Entra directory roles like “Power Platform Administrator” do not grant access to the PPAC admin APIs. You must explicitly register your app as a management application. If you don’t do this, you will get a lot of “access denied” errors as though authorization has failed when it has not.
An admin must run this interactively – the SPN cannot register itself:
Install-Module Microsoft.PowerApps.Administration.PowerShell -Force Add-PowerAppsAccount # interactive login as a Power Platform admin New-PowerAppManagementApp -ApplicationId "<your-application-id>"
PUT https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/adminApplications/{CLIENT_ID}?api-version=2020-10-01
Authorization: Bearer <admin-user-token>
The bearer token must come from an admin user’s interactive login – client credentials flow will not work for this call.
Important: This registration is a one-time operation per tenant. Once registered, the SPN can manage all environments in the tenant.
For pipelines that call F&O APIs directly (DMF entity refresh, OData smoke tests),
the SPN must also be registered inside each F&O environment.
Repeat this for each F&O environment where the SPN needs OData access (typically all of them).
Original Post https://www.atomicax.com/content/3-pre-requisites-and-app-registrations