Repository navigation
[FEATURE] SQL Database DDL via fab CLI / Fabric REST API #1004 #240
Copy link
Copy link
Open
Labels
Description
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.nettoken audience, which thefabCLI 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.sqlAlternatives 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 tablecommands 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
azCLI)
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 schemaworks for Lakehouses but returns "unsupported" for SQL Databases
Impact Assessment
- This would help me personally
- This would help my team/organization
- This would help the broader fabric-cli community
- This aligns with Microsoft Fabric roadmap items
Implementation Attestation
- I understand this feature should maintain backward compatibility with existing commands
- I confirm this feature request does not introduce performance regressions for existing workflows
- I acknowledge that new features must follow fabric-cli's established patterns and conventions
Implementation Notes
fab cli or rest api. Preferred CLI.
Reactions are currently unavailable
Activity
microsoft-github-policy-service commentedon May 28, 2026
Thank you for submitting this issue, goreavin.
A member of the Fabric CLI team will review your submission and provide feedback shortly.
goreavin commentedon May 28, 2026
For questions, please let me know.
github-actions commentedon May 28, 2026
AI Assessment: Needs Team Review
This request targets a gap in Fabric SQL Database automation—direct T-SQL execution via
fab. The value is clear: it enables CI/CD deployment scenarios and aligns with existing Lakehouse capabilities in the CLI. However, there are fundamental feasibility questions:/sqldatabases/{id}/executeQueriesdoes not exist).fabCLI cannot obtain tokens fordatabase.windows.netaudience given app registration constraints, ruling out ODBC/JDBC and sqlcmd approaches, and the CLI'sauthcommand does not support audience selection for SQL DB.fab sqlcommand would require either (a) new REST API support, or (b) a change to authentication token audience, both of which are outside the CLI project's scope and require platform-level changes.fabmanages authentication and interacts with SQL Database resources.Options B and C are out of scope for the CLI alone unless the Fabric platform exposes new API endpoints or broadens token audience allocations. Option A (
fab sql) cannot be considered until these Platform changes are addressed.Next Steps:
🔔 Escalated to team — This issue requires team review and has been flagged for attention.
github-actions commentedon May 28, 2026
🔔 @microsoft/fabric-cli-dev — This issue has been flagged by AI triage as requiring team attention. Please review the assessment above.