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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
akarkal
Frequent Visitor

Using Service Principal for REST API / Data Refresh

I have a C# App that uses a Active Directory User to perform the following operations, I am trying to convert it to use a Active Directory Service Principal. I am using Power Embedded Workspace with Premium Capacity in Azure

- Create DataSet

- Create Report

- Refresh DataSet

 

However I am running into issues when trying to get the same actions performed using a Service Principal.

I have the following things setup 

 

01. Api access granted to Service Principal

 - restricted the access to a specific group and made sure that the Service Principal I am using is added to this security group

 Screen Shot 2021-12-07 at 2.36.50 PM.png

(Screenshot : courtesey youtube video from GuyInACube (https://www.youtube.com/watch?v=1SO19uik1rw)

02. added service principal on the workspace with the role "Admin"

03. I am using AppOwnsData project from https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/.NET%20Core/Embed%20for%20your%20... and getting error

 

Operation returned an invalid status code 'Unauthorized'
at Microsoft.PowerBI.Api.ReportsOperations.GetReportInGroupWithHttpMessagesAsync(Guid groupId, Guid reportId, Dictionary`2 customHeaders, CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.ReportsOperationsExtensions.GetReportInGroupAsync(IReportsOperations operations, Guid groupId, Guid reportId, CancellationToken cancellationToken)
at Microsoft.PowerBI.Api.ReportsOperationsExtensions.GetReportInGroup(IReportsOperations operations, Guid groupId, Guid reportId)
at AppOwnsData.Services.PbiEmbedService.GetEmbedParams(Guid workspaceId, Guid reportId, Guid additionalDatasetId) in C:\Campuslabs\TeamFoundation\PowerBI-Developer-Samples\.NET Core\Embed for your customers\AppOwnsData\Services\PbiEmbedService.cs:line 46
at AppOwnsData.Controllers.EmbedInfoController.GetEmbedInfo() in C:\Campuslabs\TeamFoundation\PowerBI-Developer-Samples\.NET Core\Embed for your customers\AppOwnsData\Controllers\EmbedInfoController.cs:line 45

 

My question is

1. How do I troubleshoot this issue

2. Are Service Principal Credentials allowed to refresh / create / data sets on Power Embedded Workspace with Premium Capacity

1 ACCEPTED SOLUTION

I was able to get this to work after removing the restrictions on the security group from the tenant settings

 

these are my settings now

- tenant : api enabled for service principal, no restrictions on security group

- SP added to workspace as administrator (directly , not via a group)

 

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @akarkal,

Account to your description, it seems like you missed adding the security group that you configure with the service principal as the member of power bi embedded group workspace so that the rest API can't recognize the corresponding authentication.

Please take a look at the following link to know more about these operations:

Embed Power BI content in an embedded analytics application with service principal and an applicatio...

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

I was able to get this to work after removing the restrictions on the security group from the tenant settings

 

these are my settings now

- tenant : api enabled for service principal, no restrictions on security group

- SP added to workspace as administrator (directly , not via a group)

 

Hi @akarkal,

I'm glad to hear you found and share the workaround to resolve the issue. I think they may help if others faced a similar scenario.🙂 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors