Only in Mage Pro.Try our fully managed solution to access this advanced feature.
Overview
Microsoft Fabric Warehouse is a fully managed, cloud-native data warehouse built on Azure Synapse SQL. It provides enterprise-grade performance, scalability, and security for your data analytics workloads. This integration allows you to:- Connect to Microsoft Fabric Data Warehouse using Azure AD Service Principal authentication (with optional token-based auth via
AZURE_TENANT_ID) - Run SQL in pipelines via SQL blocks (transformer) or Python blocks
- Export data using batched row-based inserts (standard export)
Add credentials
- Create a new pipeline or open an existing pipeline.
- Expand the left side of your screen to view the file browser.
- Scroll down and click on a file named
io_config.yaml. - Enter the following keys and values under the key named
default(you can have multiple profiles, add it under whichever is relevant to you)
Configuration Parameters
| Parameter | Description | Required | Example |
|---|---|---|---|
AZURE_CLIENT_ID | Azure AD Service Principal Application ID (GUID format) | ✅ | 12345678-1234-1234-1234-123456789012 |
AZURE_CLIENT_SECRET | Azure AD Service Principal Secret | ✅ | your-secret-here |
MICROSOFT_FABRIC_WAREHOUSE_NAME | Name of your Fabric Data Warehouse database | ✅ | my_database |
MICROSOFT_FABRIC_WAREHOUSE_ENDPOINT | Fabric workspace endpoint URL | ✅ | abcde12345.datawarehouse.fabric.microsoft.com |
MICROSOFT_FABRIC_WAREHOUSE_SCHEMA | Default schema for operations | ❌ | dbo (default) |
AZURE_TENANT_ID | Azure AD tenant ID (GUID format). When set, connection uses token-based auth (OAuth2 token injected via ODBC); recommended for Fabric. When omitted, connection uses UID/PWD with ActiveDirectoryServicePrincipal. | ❌ | 87654321-4321-4321-4321-210987654321 |
Service Principal Setup
To use service principals with Microsoft Fabric Data Warehouse, you need to:- Create a service principal in Microsoft Entra ID
- Enable service principal access in Microsoft Fabric
- Assign appropriate permissions to the service principal
- Register a Microsoft Entra app and create a service principal
- Service principal in Fabric Data Warehouse
Using SQL blocks
Run SQL directly against Microsoft Fabric Warehouse from a SQL block (transformer):- Add a Transformer block and set its language to SQL.
- In the block’s connection settings, set Connection to Microsoft Fabric and Profile to your
io_config.yamlprofile (e.g.default). - Optionally set Schema (default
dbo) and Use raw SQL to run statements as-is. - Write your SQL. Reference upstream block output with
{{ df_1 }},{{ df_2 }}, etc. The block uses the profile’s credentials and schema.
- Materialized output (no “Use raw SQL”) When “Use raw SQL” is off, the block runs your query and exports the result to a table (creates or appends) by executing the query string in the warehouse. The warehouse runs the SQL directly.
-
Upstream data referenced in SQL (
{{ df_1 }},{{ df_2 }}, …) When your SQL references{{ df_1 }}(or{{ df_2 }}, etc.), the upstream block’s output must be available in the warehouse. If not already there, Mage uploads that DataFrame using batched inserts (see Export limits).
Using Python block
- Create a new pipeline or open an existing pipeline.
- Add a data loader, transformer, or data exporter block (the code snippet below is for a data loader).
- Select
Generic (no template). - Enter this code snippet (note: change the
config_profilefromdefaultif you have a different profile):
- Run the block.
Export a dataframe
Use a data exporter block and callwarehouse.export(). Data is inserted in batches (see Export limits).
Standard export
Export uses batchedINSERT statements. Use the same io_config.yaml profile as for loading. Optionally set AZURE_TENANT_ID (GUID) for token-based auth (recommended for Fabric).
Configuration: See Add credentials. Optionally add AZURE_TENANT_ID for token auth.
Code: Call warehouse.export(df, schema_name, table_name, ...) as in the example above. See Export limits for the column limit.
Export limits
- Column count: SQL Server limits the number of parameters per statement (2,000). If your DataFrame has more than 2,000 columns, export raises a clear error. Reduce the number of columns or use a different upload method (e.g. export a subset of columns, or stage data elsewhere and load via another path).
Custom types
To overwrite a column type when running a python export block, simply specify the column name and type in theoverwrite_types dict in data exporter config:
Troubleshooting errors
Connection Timeout Errors
Error:Login timeout expired or Connection timeout
“Verify your Service Principal credentials and network connectivity”
- Ensure
AZURE_CLIENT_IDis a valid GUID format - Verify
AZURE_CLIENT_SECRETis correct and not expired - Check that the Service Principal has appropriate permissions on your Fabric workspace
- Ensure the Service Principal is not disabled in Azure AD
- Verify network connectivity to the endpoint
- Check if corporate firewall or proxy is blocking the connection
- Try increasing connection timeout settings
TCP Provider Errors
Error:TCP Provider: Error code 0x2746 (10054) or Connection reset by peer
“Verify your endpoint URL and network connectivity”
- Ensure
MICROSOFT_FABRIC_WAREHOUSE_ENDPOINTis correct and accessible - Check network connectivity to the endpoint (ping, telnet, etc.)
- Verify the endpoint is accessible from your current location
- Ensure the endpoint is not blocked by firewall rules
- Check if Azure region is experiencing connectivity issues
- Verify the Microsoft Fabric service is operational
- Try connecting from a different network to isolate the issue
Database Object Errors
Error:Invalid object name 'table_name' or Database 'database_name' does not exist
“Verify your database name, schema, and table existence”
- Ensure
MICROSOFT_FABRIC_WAREHOUSE_NAMEmatches exactly (case-sensitive) - Check that the Service Principal has access to the database
- Verify the database exists in your Fabric workspace
- Ensure the database is not paused or offline
- Verify the table exists in the specified schema
- Check if you’re using the correct schema name (default is ‘dbo’)
- Ensure table names are properly quoted if they contain special characters
Authentication Errors
Error:Failed to authenticate with Azure AD or Login failed for user or Could not login because the authentication failed.
“Verify your Service Principal credentials and permissions”
- Ensure
AZURE_CLIENT_IDis a valid GUID format - Verify
AZURE_CLIENT_SECRETis correct and not expired - Check that the Service Principal has appropriate permissions on your Fabric workspace
- Ensure the Service Principal is not disabled in Azure AD
- Verify the Service Principal has the correct role assignments
- Check if the Service Principal’s permissions have been revoked
Export column limit
Error:DataFrame has X columns, which exceeds SQL Server parameter limit (2000)
“Reduce the number of columns or use a different upload method”
- Export a subset of columns (e.g. drop or select only the columns you need)
- Split the DataFrame into multiple tables
- Use a different load path if you have very wide tables (e.g. stage to storage and load via another tool)
Schema Errors
Error:Schema 'schema_name' does not exist
“Verify your schema name and permissions”
- Ensure
MICROSOFT_FABRIC_WAREHOUSE_SCHEMAis correct - Check that the Service Principal has access to the schema
- Verify the schema exists in your database
- Use ‘dbo’ as the default schema if unsure
- Check if the schema name is case-sensitive
- Verify the Service Principal has CREATE/ALTER permissions on the schema
Best Practices
-
Service Principal Management:
- Use dedicated Service Principals for different environments
- Rotate secrets regularly
- Grant minimum required permissions
-
Connection Management:
- Always use context managers (
withstatements) when possible - Close connections explicitly when not using context managers
- Test connections before running large operations
- Always use context managers (
-
Performance Optimization:
- Export uses batched inserts; keep tables under the export column limit (2,000 columns). For very wide DataFrames, reduce columns or use another load path.
- Use appropriate
if_existspolicies (‘replace’, ‘append’, ‘fail’) - Consider using
overwrite_typesfor optimal column types - Use LIMIT clauses in queries when testing
-
Security:
- Never hardcode credentials in your code
- Use
io_config.yamlfor all configuration - Ensure
io_config.yamlis not committed to version control - Use environment variables for sensitive values in production