Use Case / Problem
Title
Enable T-SQL execution against Fabric SQL Database via the Fabric REST API and fab CLI
Problem Statement
Currently, there is no way to execute T-SQL statements (DDL or DML) against a Fabric SQL Database from the fab CLI or the Fabric REST API. The only supported methods are:
- Fabric Portal — SQL Query editor (manual, not automatable)
- sqlcmd (Go) — Requires
database.windows.net token audience, which the fab CLI app registration (5814bfb4-2705-4994-b8d6-39aabeb5eaeb) does not have consent for
- pyodbc/JDBC from Spark notebooks — Fails with "Login failed for user" because the Fabric-issued Spark token doesn't have SQL Database permissions by default
This makes it impossible to automate SQL Database schema setup (CREATE TABLE, INSERT seed data) as part of a CI/CD deployment pipeline using fab CLI.
Current Workarounds (all inadequate)
| Approach |
Issue |
fab CLI table schema / table load |
Only works on Lakehouse tables, not SQL Database |
Fabric REST API /sqldatabases/{id}/executeQueries |
Endpoint does not exist (404) |
Spark notebook with spark.sql('CREATE TABLE sqldb.dbo.table') |
Cross-database DDL from Spark to SQL DB not supported |
| Spark notebook with py4j JDBC |
Token scope mismatch — database.windows.net token not obtainable via mssparkutils.credentials.getToken() in some configs |
fab api with -A powerbi |
Power BI executeQueries only supports DAX, not T-SQL against SQL Databases |
| pyodbc from external CLI |
ODBC driver available but fab auth token is scoped to api.fabric.microsoft.com, not database.windows.net |
Proposed Solution
Proposed Solution
Requested Enhancement
Option A (preferred): Add fab sql command
# Execute T-SQL against a SQL Database item
fab sql "workspace.Workspace/mydb.SQLDatabase" -q "CREATE TABLE dbo.my_table (id INT PRIMARY KEY, name VARCHAR(100))"
# Or from file
fab sql "workspace.Workspace/mydb.SQLDatabase" -i ./schema.sql
Alternatives Considered
Option B: Add REST API endpoint
POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/sqldatabases/{sqlDbId}/executeStatement
Content-Type: application/json
Authorization: Bearer {fabric_token}
{
"statement": "CREATE TABLE dbo.my_table (id INT, name VARCHAR(100))"
}
Option C: Allow fab auth to acquire database.windows.net scoped tokens
fab auth token --audience database.windows.net
# Returns a token usable with sqlcmd -S server -G --access-token <token>
Impact
- Blocks CI/CD automation for Fabric SQL Database deployments
- Forces manual portal interaction for any schema changes
- Inconsistent with Lakehouse (where
fab table commands work) and Warehouse (where Spark cross-DB queries work)
- User Data Functions that connect to SQL Databases require the staging table to exist — but there's no automated way to create it
Environment
- fab CLI version: 1.0.0 (Python-based,
fabric_cli.main)
- Workspace type: Fabric F64 capacity
- Item type: SQLDatabase (
SqlDatabase / SqlDbNative)
- SageMaker CodeEditor environment (Linux x86_64, no
az CLI)
Related
- Fabric User Data Functions can write to SQL Databases (confirmed) but the table must pre-exist
- Lakehouse SQL analytics endpoint is read-only (by design, documented)
fab table schema works for Lakehouses but returns "unsupported" for SQL Databases
Impact Assessment
Implementation Attestation
Implementation Notes
fab cli or rest api. Preferred CLI.
Use Case / Problem
Title
Enable T-SQL execution against Fabric SQL Database via the Fabric REST API and
fabCLIProblem Statement
Currently, there is no way to execute T-SQL statements (DDL or DML) against a Fabric SQL Database from the
fabCLI or the Fabric REST API. The only supported methods are:database.windows.nettoken audience, which thefabCLI app registration (5814bfb4-2705-4994-b8d6-39aabeb5eaeb) does not have consent forThis makes it impossible to automate SQL Database schema setup (CREATE TABLE, INSERT seed data) as part of a CI/CD deployment pipeline using
fabCLI.Current Workarounds (all inadequate)
fabCLItable schema/table load/sqldatabases/{id}/executeQueriesspark.sql('CREATE TABLE sqldb.dbo.table')database.windows.nettoken not obtainable viamssparkutils.credentials.getToken()in some configsfab apiwith-A powerbifab authtoken is scoped toapi.fabric.microsoft.com, notdatabase.windows.netProposed Solution
Proposed Solution
Requested Enhancement
Option A (preferred): Add
fab sqlcommandAlternatives Considered
Option B: Add REST API endpoint
Option C: Allow
fab authto acquiredatabase.windows.netscoped tokensfab auth token --audience database.windows.net # Returns a token usable with sqlcmd -S server -G --access-token <token>Impact
fab tablecommands work) and Warehouse (where Spark cross-DB queries work)Environment
fabric_cli.main)SqlDatabase/SqlDbNative)azCLI)Related
fab table schemaworks for Lakehouses but returns "unsupported" for SQL DatabasesImpact Assessment
Implementation Attestation
Implementation Notes
fab cli or rest api. Preferred CLI.