microsoft / microsoft/fabric-cli

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

Open
#240 4 comments 0 reactions 1 assignee View on GitHub

@HasanAboShally is already working on this.

Since May 31, 2026.

ai:feature-triage:needs team review ai:needs team attention enhancement
Dominant language
Python
Stars
173
Forks
63
Avg merge
2d 19h
Merged PRs (30d)
4

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:

  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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.