Forum Discussion
Not Able to connect Fabrib database using C# .Net Core API
- Anonymous1 year ago
Hi v-jdubey ,
Thank you for reaching out to the Microsoft Fabric Community forum.
Based on your explanation, it appears the issue arises when your .NET Core API, hosted on Azure App Service, attempts to connect to a Microsoft Fabric Warehouse SQL endpoint using ManagedIdentityCredential. While it works locally, it fails in Azure with the error “Could not login because the authentication failed”despite successfully acquiring an access token.This typically indicates a permissions or identity scope issue. Below are recommended steps to address it:
In the Azure portal, navigate to your App Service → Identity → System assigned → Enable. This will generate an Azure AD identity for the app. Note the Object ID for permission assignment. Please refer the following documentation for your reference:Managed Identities - Azure App Service | Microsoft Learn
In your Fabric workspace, navigate to the target Warehouse → More options (⋯) → Permissions. Add the App Service’s Managed Identity with Admin or Contributor role. Also ensure the identity has workspace-level permissions.
Permission model - Microsoft Fabric | Microsoft Learn
Use the correct Fabric SQL endpoint (typically ends with .sql.azuresynapse.net). Do not include username/password in the connection string when using Azure AD tokens.
Warehouse Connectivity - Microsoft Fabric | Microsoft Learn
Your use of ManagedIdentityCredential is appropriate for Azure-hosted environments. Just ensure this logic is environment-specific and that your local development uses DefaultAzureCredential only.
Please refer the following link: ManagedIdentityCredential Class (Azure.Identity) - Azure for .NET Developers | Microsoft Learn
By following these steps and ensuring that the Managed Identity has appropriate access to both the workspace and warehouse, you should be able to resolve the login authentication issue.
Hope this helps. Please reach out for further assistance.
If this post helps, then please consider to Accept as the solution to help the other members find it more quickly and a kudos would be appreciated.
Thank you.
Hi v-jdubey ,
Just wanted to check if you had the opportunity to review the suggestion provided?
If the response has addressed your query, please Accept it as a solution so other members can easily find it.
Thank You
- NiharP1 year ago
Microsoft Employee
Hi Anonymous ,
We've verified all the options, everything looks appropriate. Except for the connection string. The connection string which we're using ends with msit-datawarehouse.fabric.microsoft.com. Does this create any issue.
Thank You