Skip to main content

When creating integrations with Dynamics 365, one of the common steps is to set up a service principal in Azure. There are several steps to set this up, including:

  • Creating an Azure App Registration
  • Creating a secret
  • Setting up API permissions
  • Creating an Application User in the Power Platform Admin Center
  • Assigning permissions to that Application User

What if I told you you can do all of this with one PowerShell command? Let’s take a look at pac admin create-service-principal.

First, get the Environment Id for your org, which you will find in the Power Platform Admin Center here:

Open the pac cli in PowerShell and run the command below to connect to your environment:

pac auth create -env <environment id>

Make sure your org is properly selected (if you have other connections) with pac auth select.

Now run the command below to create the service principal:

pac admin create-service-principal --environment <environmentid>

You can see above, this has created everything for us. We can see in Azure the new app registration with secret created:

And API Permissions:

And Application user with System Admin privileges (note you can add a parameter to the command to set the role with -r, but default is System Admin):

That’s it! You have now probably saved a whole lot of time and can start building those integrations.

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.

 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET’S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

ABOUT CARL DE SOUZA

Source