Forum Discussion
publish and create workspace security using power bi and azure
- 1 year ago
Thankyou, Deku, for your response.
Hi erico_vincentci,We appreciate your inquiry submitted through the Microsoft Fabric Community Forum.
Based on my understanding of your setup and the 'Unauthorized' error you are encountering, the issue appears to be related to Service Principal authorization within Power BI.
Kindly follow the steps outlined below, which may help resolve the issue:
-
Navigate to the Power BI Admin Portal and enable the options "Allow service principals to use Power BI APIs" and "Allow service principals to create and view content." You may assign access to a security group or temporarily allow access for the entire organisation.
-
Proceed to the Azure Portal, go to App Registrations, and select your application. Add and grant admin consent for the required application permissions, such as Dataset.ReadWrite.All, Report.ReadWrite.All, and Workspace.ReadWrite.All.
-
In the Power BI Service, open your workspace (testing-id). Go to Access and add your Azure AD App as a Contributor or Admin.
-
Ensure that your application is registered in the same tenant where Power BI is hosted. Also, verify that you are not using a personal or guest account.
-
Confirm that your application is registered in Azure AD with a valid Client ID, Tenant ID, and Client Secret. Ensure your app uses the correct Client ID, Client Secret, and Tenant ID to authenticate with the Power BI API.
For your reference, please find the following link:
Embed Power BI content in an embedded analytics application with service principal and an application secret - Power BI | Microsoft LearnIf you find our response helpful, kindly mark it as the accepted solution and provide kudos. This will assist other community members facing similar issues.
Should you have any further queries, please feel free to contact the Microsoft Fabric community.
Thank you.
-
I've not used the c# library but some point below from using the rest API.
Assume you are using a service principal as per the link.
Did you grant the SPN permission to run APIs in the tenent setting?
If you are running a non admin API the SPN will also need permissions in the workspace, looks like contributor might be sufficient in your case.
Some detail here that might be useful
https://www.youtube.com/live/swnGlrRy588?si=qVfeM45oaGulcjqc