Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
rbroida
Helper I
Helper I

How to use MSAL to create PowerBIClient in C# with AAD application credentials

I'm writing a C# program to perform administrative tasks in Power BI Embedded such as creating, updating, and deleting workspaces, datasets, and reports. I am using the Nuget library "Microsoft.PowerBI.Api Version=3.31.2". It appears I need to create an instance of the Microsoft.PowerBI.Api.PowerBIClient. I want it to authenticate using the credentials of an AAD registered application (not the credentials of a user). I've created an AAD app registration and given it permission to call the entire Power BI API. I have the application's clientid, client secret, and tenantid. But I can't figure out which PowerBIClient constructor to use so that it can utilize the credentials of my AAD application. Apparently I need to pass a ServiceClientCredentials object to the PowerBIClient constructor, but ServiceClientCredentials is an abstract class, and I can't figure out how to use the application's clientid, client secret, and tenantid to construct something that derives from ServiceClientCredentials. The only examples I found searching online use ADAL, but that's deprecated, so if an external library is needed I want to use MSAL. Can someone please show me a code sample showing how to create a PowerBIClient using the credentials of an AAD app, using MSAL if necessary. Thank you.

1 ACCEPTED SOLUTION
rbroida
Helper I
Helper I

I found the answers in this 30 minute video from SqlBi: Creating a service principal account for Power BI API - SQLBI

 

I feel flattered that Marco Russo was stumped on this for two days, while I only wasted one. 😀 Microsoft, it would sure be good if the documentation explained this.

View solution in original post

1 REPLY 1
rbroida
Helper I
Helper I

I found the answers in this 30 minute video from SqlBi: Creating a service principal account for Power BI API - SQLBI

 

I feel flattered that Marco Russo was stumped on this for two days, while I only wasted one. 😀 Microsoft, it would sure be good if the documentation explained this.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors