Forum Discussion
C# XMLA TOM Connection Failing
- 9 months ago
v-sgandrathi GilbertQ I appreciate the back and forth you've provided. I have been unable to get the Tabular Object Model to work. However, I have found a way using the ADOMD connection to get the datasource names that includes the actual table or view named used in each Power BI report and this helps.
Again thank you for your time. I may revisit this as I'd like to figure out how to get TOM to work. I'm not sure if it's my .Net Framework, if it needs Core or something else.
Hi TCavins,
Thank you for providing the screenshot. Your Power BI Service API permissions are currently set as Delegated, which are for user sign-in authentication. Since you're using a service principal and app-only authentication, you need to set these permissions as Application instead. Keep the same scopes App.Read.All, Dataset.ReadWrite.All, Report.ReadWrite.All, SemanticModel.ReadWrite.All, and Workspace.ReadWrite.All, but add them under Application and grant admin consent in Azure AD.
Then, in the Power BI Admin Portal - Tenant Settings, confirm that service principals can use Power BI APIs and that the XMLA endpoint is enabled with Read/Write access. Also, make sure your workspace is in PPU or Premium capacity and that your service principal is set as an Admin for that workspace.
Once these changes are made, use token-based authentication instead of User ID and Password. Obtain the token with the Microsoft Authentication Library (MSAL), and connect using a string like:
DataSource=powerbi://api.powerbi.com/v1.0/myorg/<WorkspaceName>;Password=<access_token>;
You don't need to change myorg to your domain, as this format is required by Power BI. These steps should help resolve “invalid connection string” or “format exception” errors when connecting through TOM.
Thank you.
v-sgandrathi Thank you for your reply. I read somewhere today that Premium Per User workspaces cannot use a service principal. So, I tried to do it with an interactive token but I still get the same invalid connection string error.
When I go to the Application API permissions, I only see two entries.
So, this led me down to make sure I have other items set up correctly and screenshots are below:
XMLA Endpoint:
Service Principal permissions - all set with a security group that the service principal is a member of:
Am I missing something else?
- GilbertQ9 months ago
Super User
PPU workspaces can use Service Principals. All workspaces can use Service Principals, you just need to add them to the Roles for each App Workspace.
- TCavins9 months ago
Helper V
GilbertQ The service principal has direct access and also through the security group. I tried each one individually but I still get the same error.
From my readings, it doesn't sound like I can assign Application permissions in the Azure App for Power BI, it has to be delegated permissions but this goes against what v-sgandrathi has suggested. So I don't know if I need to apply additional settings/permissions as to what I've shared in screenshots or if I need to try something else.
I've verified through SSMS that I can connect to the powerbi://api.powerbi.com endpoint so it's not a network/firewall issue. At least I don't think so.