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

Join us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered

Reply
jigmoth
New Member

C# to Lakehouse SQL Analytics Endpoint not connecting

I have a console app in C# .net framework. I am trying to connect MS Fabric Lakehouse SQL Analytics Endpoint using Service Principal, but it always gives me error 'Could not login because the authentication failed.', when i researched i found in community (authenticate to Fabric Data Warehouse with Service... - Microsoft Fabric Community) it says in SQL query window Create a user with your service principal name and add db_owner role. But when i tried to execute the query it says 'CREATE USER is not a supported statement type.' Its a deadlocak, i want to access Lakehouse tables from C# without user interaction login. Kindly Assist.

 

//Not working
string connectionString = @"Data Source=msfabricendpoint.datawarehouse.fabric.microsoft.com,1433;
Initial Catalog=insights_LH_PRD;
Authentication=Active Directory Service Principal;
User ID=[ClientId];
Password=[Client_Secret]";
Encrypt=True;
TrustServerCertificate=False;";

 

SqlConnection conn = new SqlConnection(connectionString);
conn.Open();

6 REPLIES 6
Anonymous
Not applicable

Hi @jigmoth ,

Thanks for using Fabric Community.
The answer provided for this thread - authenticate to Fabric Data Warehouse with Service... - Microsoft Fabric Community assuming user would like to connect Azure SQL using pyodbc in Fabric via Service Principal..

vgchennamsft_2-1715315167706.png


If you are tring to connecting MS Fabric Lakehouse SQL Analytics Endpoint using Service Principal

Note: After creating Service Prinipal in Azure Entra ID. 
You need to add service principal to Fabric workspaces like this:

vgchennamsft_0-1715315066472.png

 

Make sure to allow access to service principals by enabling below option in Admin Portal:

vgchennamsft_1-1715315066553.png


After providing the access you should be able to do the connection using Service Principal.

Docs to refer - 
c# - Generating token for Fabric Rest api using client secret - Stack Overflow
Connectivity to data warehousing - Microsoft Fabric | Microsoft Learn

vgchennamsft_3-1715315445808.png


Hope this is helpful. Please let me know incase of further queries.

Thank you for responding, for me i cannot see Tenant settings options and many other menus, i can only see Capacity Settings & Help Support. What am i missing here?

jigmoth_0-1715347281192.png

 

Anonymous
Not applicable

Hi @jigmoth ,

It looks like you do not have the necessary permissions.

I can find a similar thread -
Solved: Admin Portal Only Has Capacity Settings ONLY - No... - Microsoft Fabric Community

Thank you

Anonymous
Not applicable

Hello @jigmoth ,

We haven’t heard from you on the last response and was just checking back to see if you have a resolution yet .
In case if you have any resolution please do share that same with the community as it can be helpful to others .
Otherwise, will respond back with the more details and we will try to help .
Thanks

Hello, Yes this worked for me thank you. Appreciate you help.

Anonymous
Not applicable

Hi @jigmoth ,

Glad to know that your issue got resolved. Please continue using Fabric Community on your further queries.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

May FBC25 Carousel

Fabric Monthly Update - May 2025

Check out the May 2025 Fabric update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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