Any CDS trigger or action requires a connection to CDS environment.
While adding connection, we can choose to sign in with individual user account or Service Principal.
If we choose to sign in with individual user , CDS action runs in that user context and in auditing it shows as the user performed that action.
It may cause problems in some scenarios like audit checks/troubleshooting.
So better way to do it is sign in with service principal / application user. By creating service principal, we are indirectly creating an identification for the flow.
A service principal is created by registering an Azure AD application and then creating a corresponding application user in CDS.
When you use an application user/service principal on the CDS connector all actions are performed by that user on behalf of organization users who are triggering the flow by performing some action (Which is called impersonation ).
Application users get the permissions from the security roles associated with the CDS app user.
Below steps are required to create Service Principal / Application user.
Step 1: Register your application in Azure Active Directory.
Refer this article from Microsoft docs to create application in Azure AD. And note down client id/application id, client secret , tenant id .
Step 2 : Create application user in CDS environment and assign security role(custom).
Refer this article from Microsoft docs to create application user and assign security role.
Step 3: Add new connection and sign in with service principal in flow.
Enter client id/application id, client secret, tenant/directory id that we got from Step 1 and click on create.
That’s it .
Hope it helps.
Original post from my blog : https://powerofpowerplatform.com/using-service-principal-in-power-automate-flow/