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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
bhavya5903
Advocate II
Advocate II

How to connect Fabric SQL Database in VS Code using C# or Python with non-interactive authentication

Hi all,

I’m currently working on a data migration project using VS Code, where the destination is a Microsoft Fabric SQL Database. I'm able to successfully connect and write data using C#, but the authentication is currently happening through interactive login (browser-based prompt) using DefaultAzureCredential.

Instead, I want to authenticate non-interactively, i.e., by passing credentials (client ID, secret, tenant ID, etc.) in the code, so the process can be automated.

Has anyone successfully configured this using either:

  • ClientSecretCredential in C#

  • DefaultAzureCredential/ClientSecretCredential in Python

If yes, could you please share:

  • Which credentials setup is supported by Fabric for this?

  • The right authentication flow and permission requirements for this?

  • Any working code snippet or documentation link?

Thanks in advance!

1 ACCEPTED SOLUTION
v-kpoloju-msft
Community Support
Community Support

Hi @bhavya5903,

Thanks for sharing your scenario in the Microsoft Fabric Community. I understand you want to connect to a Microsoft Fabric SQL Database from VS Code using non-interactive authentication (Client ID, Client Secret, Tenant ID) instead of the current browser-based interactive login.

In Microsoft Fabric, the supported approach for service-to-service (non-interactive) connections is to use an Azure AD app registration with the Client Credentials flow. You will need to do these below mentioned steps.

Register an application in Azure AD: Go to Azure Portal → Azure Active Directory → App registrations → New registration. Note the Application (client) ID, Directory (tenant) ID. Create a Client Secret under Certificates & secrets.

Assign permissions to the app: In the Fabric workspace, grant the Azure AD app the necessary role (e.g., Contributor or Member). Ensure the app has Database permissions in the Fabric SQL endpoint.

Use ClientSecretCredential in your code:
C# example: ClientSecretCredential Class (Azure.Identity) - Azure for .NET Developers | Microsoft Learn.
Python example: azure.identity.ClientSecretCredential class | Microsoft Learn.

Connection string format: Fabric SQL Database uses the Azure SQL connection syntax, so once you have a token from ClientSecretCredential, you can connect via SqlConnection in C# or pyodbc / sqlalchemy in Python.

Also, additional documentation links are mentioned below those might be helpful:
What is the SQL analytics endpoint for SQL database in Fabric? - Microsoft Fabric | Microsoft Learn
Microsoft Entra authentication - Azure SQL Database & Azure SQL Managed Instance & Azure Synapse Ana...
Microsoft Entra authentication - Azure SQL Database & Azure SQL Managed Instance & Azure Synapse Ana...

Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.

Thank you for using the Microsoft Community Forum.

View solution in original post

3 REPLIES 3
v-kpoloju-msft
Community Support
Community Support

Hi @bhavya5903,

Thanks for sharing your scenario in the Microsoft Fabric Community. I understand you want to connect to a Microsoft Fabric SQL Database from VS Code using non-interactive authentication (Client ID, Client Secret, Tenant ID) instead of the current browser-based interactive login.

In Microsoft Fabric, the supported approach for service-to-service (non-interactive) connections is to use an Azure AD app registration with the Client Credentials flow. You will need to do these below mentioned steps.

Register an application in Azure AD: Go to Azure Portal → Azure Active Directory → App registrations → New registration. Note the Application (client) ID, Directory (tenant) ID. Create a Client Secret under Certificates & secrets.

Assign permissions to the app: In the Fabric workspace, grant the Azure AD app the necessary role (e.g., Contributor or Member). Ensure the app has Database permissions in the Fabric SQL endpoint.

Use ClientSecretCredential in your code:
C# example: ClientSecretCredential Class (Azure.Identity) - Azure for .NET Developers | Microsoft Learn.
Python example: azure.identity.ClientSecretCredential class | Microsoft Learn.

Connection string format: Fabric SQL Database uses the Azure SQL connection syntax, so once you have a token from ClientSecretCredential, you can connect via SqlConnection in C# or pyodbc / sqlalchemy in Python.

Also, additional documentation links are mentioned below those might be helpful:
What is the SQL analytics endpoint for SQL database in Fabric? - Microsoft Fabric | Microsoft Learn
Microsoft Entra authentication - Azure SQL Database & Azure SQL Managed Instance & Azure Synapse Ana...
Microsoft Entra authentication - Azure SQL Database & Azure SQL Managed Instance & Azure Synapse Ana...

Hope this helps clarify things and let me know what you find after giving these steps a try happy to help you investigate this further.

Thank you for using the Microsoft Community Forum.

One key point to add to these instructions is to check that the service principal can in fact login to the Microsoft Fabric SQL Database.

 

One way to check this is by logging into the database as a service principal with the aest version of SQL Server management Studio.

Hi @bhavya5903,

Just checking in to see if the issue has been resolved on your end. If the earlier suggestions helped, that’s great to hear! And if you’re still facing challenges, feel free to share more details happy to assist further.

Thank you.

Helpful resources

Announcements
December Fabric Update Carousel

Fabric Monthly Update - December 2025

Check out the December 2025 Fabric Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.