Tip #1450: Create Dataverse app users like a boss using pac cli

In another universe we did talk about Tip #545: Create non-interactive user like a boss. Since then, the product name has changed at least 27 times, Marketing Pilot and Parature came and went, Dataflex and CDS left their mark but, most importantly, we’ve got ourselves app users based on service principals.

It’s been quite a painful manual process creating those users: in Azure portal create an app registration, create a secret, add API permissions – NO, STOP DOING IT PEOPLE, IT’S NOT NEEDED, forget to copy the secret, go back 2 steps, generate new secret, switch to Dataverse admin, create an app user, assign appropriate roles (“appropriate” != “system administrator”). Switching between admin centers, tedious is the word to describe the experience.

But tedious it is no more and there is no PowerShell in sight! Behold, administrators!

pac admin create-service-principal \
   -n "LOLZ App" -r "Basic User" 

# -n name and -r role, respectively

The result:

@georged ➜ /workspaces $  -n "LOLZ App" -r "Basic User"
Connected as doug@aperturescience.click
Creating Entra ID Application 'LOLZ App'... Done
Creating Entra ID Service Principal... Done

Connected to... Candlestick Maker
Registering Application 'D4E4C8F1-9A3B-4D0A-8E7C-2E5A4F6D1B9D' with Dataverse... Done
Creating Dataverse system user and assigning role... Done

Application Name         LOLZ App
Tenant Id                3F2504E0-4F89-11D3-9A0C-0305E82C3301
Application Id           6B29FC40-CA47-1067-B31D-00DD010662DA
Service Principal Id     F47AC10B-58CC-4372-A567-0E02B2C3D479
Client Secret            pO~8Q~Really?~Z2sdwvDwgM_HowsThatWorkingOutForYou?_aT2
Client Secret Expiration 03/24/2025 09:17:05 +00:00
System User Id           0e68ef5a-bfe9-ee11-a204-dead4beeff1c

@georged ➜ /workspaces $ 

That’s it! Read Microsoft Power Platform CLI admin command group – Power Platform | Microsoft Learn as the official source of truth.

I got a bit excited and didn’t check the references before writing the above. Awesome Carl de Souza got their first. Creating Service Principals Really Easily Using Pac Cli. Unlike me, Carl has patience to produce screenshots and detailed instructions, go check it out.

Like a boss meme

Leave a Reply

Your email address will not be published. Required fields are marked *