Skip to content

[FEATURE] SQL Database DDL via fab CLI / Fabric REST API #1004 #240

Open

Description

@goreavin

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:

  1. Fabric Portal — SQL Query editor (manual, not automatable)
  2. sqlcmd (Go) — Requires database.windows.net token audience, which the fab CLI app registration (5814bfb4-2705-4994-b8d6-39aabeb5eaeb) does not have consent for
  3. 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

  • 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.

Activity

  1. microsoft-github-policy-service commented on May 28, 2026

    @microsoft-github-policy-service

    Thank you for submitting this issue, goreavin.
    A member of the Fabric CLI team will review your submission and provide feedback shortly.

  2. goreavin commented on May 28, 2026

    @goreavin
    Author

    For questions, please let me know.

  3. github-actions commented on May 28, 2026

    @github-actions

    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:

    • The Fabric REST API currently offers no SQL execution endpoint for SQL Databases (/sqldatabases/{id}/executeQueries does not exist).
    • The fab CLI cannot obtain tokens for database.windows.net audience given app registration constraints, ruling out ODBC/JDBC and sqlcmd approaches, and the CLI's auth command does not support audience selection for SQL DB.
    • Implementing a fab sql command 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.
    • This would touch core architectural boundaries — specifically, how fab manages 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.


    💡 If this issue requires the team's attention and was not escalated, you can tag @microsoft/fabric-cli-dev to notify the team.

  4. github-actions commented on May 28, 2026

    @github-actions

    🔔 @microsoft/fabric-cli-dev — This issue has been flagged by AI triage as requiring team attention. Please review the assessment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions