C3 AI Documentation Home

Connect to Microsoft Fabric Using Azure AD Authentication

Overview

Microsoft Fabric SQL Databases can be configured using Azure Active Directory (AD) authentication through either Managed Identity or Service Principal. These methods enable the C3 AI Platform to authenticate using Azure‑managed identities rather than database credentials or shared secrets. This guide discusses how to configure and authenticate Microsoft Fabric using Azure AD credentials. This guide also describes how to infer the source type and fetch data from an SQL table.

Before You Begin

Ensure the following prerequisites are met:

  • A Microsoft Fabric SQL Database / SQL Endpoint: Connect to a Microsoft Fabric SQL endpoint via a fully qualified server hostname and port.
  • Credentials for the selected authentication method
  • Access permissions on the Microsoft Fabric SQL Database: The authenticated identity must have sufficient permissions.
  • Network connectivity to Fabric SQL over the required port (1433): The connection uses the standard SQL port 1433.

Method 1: Authenticate using Azure AD Service Principal

Azure AD Service Principal authentication provides a secure way for applications to access Microsoft Fabric resources without relying on user accounts. Service Principal authentication requires manual management of credentials, typically a client secret or certificate.

Note: Create an Azure AD Service Principal if you do not already have one. See Create Azure AD Service Principal and Managed Identity for more information.

Step 1: Create an SQL Source System

Register a new SQL source system to connect to a Microsoft Fabric SQL database.

Python
sys = c3.SqlSourceSystem.make().withName("TestFabricADSP").upsert()

Step 2: Configure JDBC Credentials

Provide the Fabric SQL endpoint, port, datastore type, and Service Principal credentials. Set Authentication and connection properties.

Python
creds = c3.JdbcCredentials.fromServerEndpoint(<SERVER_ENDPOINT>, 
    1433, 
    c3.Jdbc.DatastoreKind.MSFABRIC,  
    <DATABASE_NAME>, None,  
    <CLIENT_ID>,  
    <CLIENT_SECRET>);  

## Set authentication and connection properties 
creds = creds.withProperties(c3.Map.ofStrToAny("authentication", "ActiveDirectoryServicePrincipal", "encrypt", "true", "trustServerCertificate", "false"))

Step 3: Attach Credentials to the System

Python
sys.setCredentials(creds) 

Step 4: Verify Connectivity

Verify the connection by performing a simple connectivity test. Run the following command:

Python
sys.ping() 

When the connection is configured correctly, the command returns the following:

JSON
{  
    "type" : "PingResult",  
    "reachable" : true  
} 

Method 2: Authenticate Using Azure AD Managed Identity

Azure AD Managed Identity authentication provides a secure, passwordless way for Azure‑hosted applications to access Microsoft Fabric resources. Managed identities are automatically created and managed by Azure, eliminating the need to store or rotate secrets.

Note: Create an Azure AD Managed Identity if you do not already have one. See Create Azure (AD) Credentials for more information.

Step 1: Create a Source System

This defines a logical SQL source in C3 for your Fabric connection.

Python
sys2 = c3.SqlSourceSystem.make().withName("TestFabricADMI").upsert() 

Step 2: Configure Managed Identity Credentials

Fabric uses Microsoft Entra tokens via the Workspace Identity, so no password/secret is stored.

Python
creds2 = c3.JdbcCredentials.fromServerEndpoint ("tj322u7hsnoeroravsbjbvzffm-coijqz5ljzrudhhqjjoiv4ddm4.database.fabric.microsoft.com", 
    1433, 
    c3.Jdbc.DatastoreKind.MSFABRIC, 
    "<DATABASE_NAME>", None,<MANAGED_CLIENT_ID>, 
    None); 

## Set authentication and connection properties 
creds2 = creds2.withProperties(c3.Map.ofStrToAny("authentication", "ActiveDirectoryManagedIdentity", "encrypt", "true", "trustServerCertificate", "false"))

Step 3: Attach Credentials to the System

Python
sys2.setCredentials(creds2) 

Step 4: Verify Access and List Tables

Input:

Python
sys2.ping() 

Output:

JSON
{  

 "type" : "PingResult",  
 "reachable" : true 

} 

Input:

Python
sys2.connect().listTableNames() 

Output:

JSON
{   "type" : "JdbcListTableNamesResult", 
    "names" : [ "Address", "Customer", "CustomerAddress", "Product", "ProductCategory", "ProductDescription", "ProductModel", "ProductModelProductDescription" ] 
} 

Infer Source Type

You can infer the entity type definition from an external SQL table.

Create A Source Collection

Python
coll = c3.SqlSourceCollection.builder().name("Address").sourceSystem(sys2).build().upsert() 

Infer The Type

Input:

Python
srcType = coll.inferSourceType2();
srcType = c3.pkg().upsertType(None, srcType.toString())
srcType.toString()

Output: The system looked at the source table and generated the entity definition automatically.

Python
"entity type Address mixes External, NoSystemCols, Source schema name '[SalesLT].[Address]' {\n\n  @db(dataTypeOverride='int32')\n  id: string schema name 'AddressID'\n\n  addressline1:  string schema name 'AddressLine1'\n"

Fetch Data from the Fabric SQL Table

Once the type is generated, fetching data is straightforward.

Input:

Python
c3.Address.fetch()

Output:

result
Address Table
Was this page helpful?