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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
cmjcf
Frequent Visitor

Cannot access Admin APIs with service principal via ADF

I'm trying to get Azure Data Factory to read data from the Power BI REST API, and I'm almost at the point of giving up.  After several false starts, I've got to the following (step numbers are in reference to the documentation) :

  • Step 1: I have created a service principal in the Entra tenant
    cmjcf_5-1724428904863.png
  • Step 2/3: I have created a security group in the Entra tenant, and added the SP to it
  • Step 4: I have enabled the relevant settings in Fabric tenant admin, and added the SG to the groups that can access admin APIs
    cmjcf_0-1724427071578.png
  • I have removed all permissions from Entra, per the documentation stating that they are not required, and in the case of consent-required permissions, must not be applied
    cmjcf_1-1724427239734.png
  • I've added the API with the SP details as a linked service in ADF
    cmjcf_2-1724427372289.png
  • I've created a dataset for one of the request types
    cmjcf_3-1724427476768.png
  • I've added the dataset as a source on a Data Flow
    cmjcf_4-1724427630622.png

When I try and run the Data Flow in debug mode, I get the following:

Error: at Source 'source1': Failure to read most recent page request: DF-REST_001 - Error response from server: Some({"error":{"code":"PowerBINotAuthorizedException","pbi.error":{"code":"PowerBINotAuthorizedException","parameters":{},"details":[],"exceptionCulprit":1}}}), Status code: 401. Please check your request url and body. (url:https://api.powerbi.com/v1.0/myorg/admin/groups,request body: None, request method: GET)

When I try running the same in Hoppscotch (RIP Postman), I can get a token, but I still get a 401 with the following:

 

 

 

{
  "error": {
    "code": "PowerBINotAuthorizedException",
    "pbi.error": {
      "code": "PowerBINotAuthorizedException",
      "parameters": {},
      "details": [],
      "exceptionCulprit": 1
    }
  }
}

 

 

 

I have verified that the tenant ID and application ID, along with the client secret, are correct.  I can access the non-admin APIs just fine.  I tried using the object ID instead of the application ID but that results in the following error:

Failed to get access token by using service principal. Error: unauthorized_client, Error Message: AADSTS700016: Application with identifier 'e2e9978f-6d27-40da-974b-3bff70258121' was not found in the directory [...]

I've looked at several resources already and just can't think of what I might be missing here.  I found exactly one result on Google for the combination of the ADF and API errors, and it doesn't say anything useful - it just repeats what's in Step 4 of the documentation, which I have already done.

 

No generic responses please, I've read them already and they weren't helpful.

1 ACCEPTED SOLUTION
cmjcf
Frequent Visitor

Gave up, went through the instructions again with a new service principal, and now it works.

 

¯\_(ツ)_/¯

View solution in original post

4 REPLIES 4
cmjcf
Frequent Visitor

Gave up, went through the instructions again with a new service principal, and now it works.

 

¯\_(ツ)_/¯

v-yangliu-msft
Community Support
Community Support

Hi  @cmjcf ,

 

According to the documentation, when using the PBI admin REST API with service principal authentication,” When running under service prinicipal authentication, an app must not have any admin-consent required premissions for Power BI set on it in the Azure portal. ”

vyangliumsft_0-1724662423828.png

Admin - Datasets GetDatasetUsersAsAdmin - REST API (Power BI Power BI REST APIs) | Microsoft Learn

According to my understanding, this means you can try removing all PBI-related API permissions, keeping only the tenant settings enabled, and then check if the API can successfully run using service principal authentication

 

vyangliumsft_1-1724662423836.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yangliu-msft,

 

I think we're getting confused somewhere.  In case you're not familiar with the Entra API Permissions blade, the text in that second heading is "Other permissions granted for <tenant name>".  The service principal doesn't have any of those permissions.  Those are listed as available, because it previously had them, but I removed them, because the documentation stated that they weren't needed and they weren't working anyway.  It only has the single permission listed under "Configured permissions".

Did you do anything differently the second time around? Do you have a link to the steps you followed?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors