Support Microsoft Entra ID auth for Fabric connections#7
Merged
Conversation
Fabric connections were routed straight to the MSSQL factory, which indexes raw["username"] and raw["password"] unconditionally. Bruin's Fabric connection also accepts a service principal (client_id, client_secret, tenant_id) or the DefaultAzureCredential chain, and those payloads carry no username, so building the client raised KeyError: 'username'. pymssql cannot carry a Microsoft Entra ID access token, so give Fabric its own factory: the two Entra ID modes acquire a token via azure-identity and hand it to pyodbc through the msodbcsql SQL_COPT_SS_ACCESS_TOKEN pre-connect attribute, while SQL authentication keeps using the shared pymssql path. The ODBC driver defaults to the newest installed "ODBC Driver NN for SQL Server" and can be pinned with a driver field on the connection. A payload with none of the three credential sets now raises ConnectionParseError naming the fields it expects.
iremcaginyurtturk
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
fabricconnections were mapped directly to the MSSQL client factory, which unconditionally readsraw["username"]andraw["password"]. Bruin's Fabric connection supports three auth modes, and two of them carry no username:use_azure_default_credential: true(DefaultAzureCredential chain)client_id+client_secret+tenant_id(Entra ID service principal)username+password(SQL authentication)Anyone on a service principal — the standard setup for Fabric — hit
KeyError: 'username'as soon as the client was created.Changes
Fabric gets its own factory. pymssql has no way to present a Microsoft Entra ID access token, so the two Entra ID modes acquire a token through
azure-identityand pass it topyodbcvia the msodbcsqlSQL_COPT_SS_ACCESS_TOKENpre-connect attribute. SQL authentication continues to use the existing pymssql path, so nothing changes for connections that already worked.ODBC Driver NN for SQL Server, and can be pinned via adriverfield on the connection.ConnectionParseErrornaming the fields it expects, rather than a bareKeyError.bruin-sdk[fabric]now pulls inpyodbcandazure-identity."true") are handled by a shared_as_boolhelper, which the GCP ADC check now reuses.Notes
The Entra ID modes need an ODBC Driver for SQL Server (msodbcsql18 or newer) on the machine running the asset; the README documents this alongside the auth matrix.