Create a service principal with Power Platform CLI
Create a service principal with Power Platform CLI
Introduction
To perform an integration with Dynamics 365 you typically need to set up a service principal in Azure.
To achieve this goal you must complete several steps:
- Create an Azure App Registration
- Create a secret for that App Registration
- Set up API permissions for Dynamics 365
- Create an Application User in the Power Platform Admin Center
- Assign permissions to the Application User
A tutorial to perform those actions : https://dynamics-chronicles.com/article/step-step-connect-d365-clientsecret-use-apis
All these manual steps take time. But you can perform them with a Powershell command (pac admin create-service-principal).
Create your service principal
First you have to install Power Platform CLI on your machine.
Power Platform CLI is a command-line interface used to perform various operations in the Power Platform related to environment lifecycle, authentication, and work with Dataverse environments, solution packages, portals, code components.
You can download the MSI file here : https://aka.ms/PowerAppsCLI
Power Platform CLI reference guide : https://learn.microsoft.com/en-us/power-platform/developer/cli/reference/tool
After installing Power Platform CLI open a Powershell command prompt and type the command pac to check that the installation was successful.

Then type the following command to update to the latest version.
pac install latest
Next step is to connect to your Dataverse environment with an authentication profile.
To get a list of all authentication profiles type the following command :
pac auth list

As you can see I have no authentication profile installed.
To create a profile type the following command:
pac auth create -env

You will be asked to provide your credentials. Below the result :

The last step is to use the command below :
pac admin create-service-principal --environment

Now you can check the result in your Azure Portal.
As you can see below a new App Registration has been created.

A secret with one year validity has been created for the App Registration.

And correct permissions have also be added.

You can see your new application user in the Power Platform Admin Center.

The application user has the security role 'System administrator'.
It is the default security role when you use the command pac admin create-service-principal.
If you want to associate another security role you have to use the option --role.
pac admin create-service-principal --environment --role
Where
Below the command to create a service principal with security role 'Sales Manager' assigned to the application user.

Create a service principal with Power Platform CLI
Published on:
Learn moreRelated posts
Microsoft 365 & Power Platform Community Call – May 7th, 2026 – Screenshot Summary
Call Highlights SharePoint Quicklinks: Primary PnP Website: https://aka.ms/m365pnp Documentation & Guidance SharePoint Dev Videos Issues...
How to Mask Dataverse Field values in Microsoft Power Platform using Masking Rules
Introduction In modern business applications, protecting sensitive data is no longer optional. Organizations using Microsoft Dataverse often s...
Power Platform and Tenant Level Analytics
Today I’m looking at the Tenant Level Analytics setting. The Power Platform Admin Center is getting more and more features that we would...
Microsoft 365 & Power Platform Call (Microsoft Speakers) – May 5th, 2026 – Screenshot Summary
Call Highlights SharePoint Quicklinks: Primary PnP Website: https://aka.ms/m365pnp Documentation & Guidance SharePoint Dev Videos Issues...
Power Platform – Backup retention of Production environments is changing from 28 to 7 days
Starting May 11, 2026, the default backup retention for Power Platform environments will be changed from 28 days to 7. All environments will c...
🚀 Power Platform Solution Architect Roadmap (with Modern AI Skills)
The role of a Power Platform Solution Architect is rapidly evolving. It’s no longer just about building apps—it’s about designing intelligent,...
Power Platform – Enable Managed Environment to extend storage retention period
As of April 30, 2026, the default system backup retention period for Power Platform environments is 7 days. How does this affect me? System ba...
Invisible Power Platform Connection References
On a Power Platform with multiple developers Connections and Connection references can be tricky. You have some connection references added to...
Power Platform – Please hard refresh your active long-running browser tab(s)
We are completing a platform update across Power Platform that started on April 29, 2026, and is anticipated to be completed by May 31, 2026. ...