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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
v-gchenna-msft
Community Support
Community Support

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

 

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

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.

Hi @jigmoth ,

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

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Expanding the Synapse Forums

New forum boards available in Synapse

Ask questions in Data Engineering, Data Science, Data Warehouse and General Discussion.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayFBCUpdateCarousel

Fabric Monthly Update - May 2024

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