Microsoft Fabric CLI (Python)

raw JSON →
1.5.0 verified Mon Apr 27 auth: no python

Command-line interface for managing Microsoft Fabric workspaces, lakehouses, and pipelines. Current version 1.5.0, Python 3.10–3.13. Released monthly.

pip install ms-fabric-cli
error ERROR: The request is invalid because the workspace name contains invalid characters.
cause Workspace names must be URL-safe (letters, numbers, hyphens, underscores).
fix
Rename workspace to use only allowed characters.
error ModuleNotFoundError: No module named 'ms_fabric_cli'
cause The package is not importable as a Python module; it installs a CLI binary only.
fix
Use the command-line tool directly: 'fabric --help'. Do not try to import it in Python.
breaking From v1.5.0, 'fabric lakehouse create' requires '--lakehouse-name' flag; '--name' is deprecated and will be removed in v2.0.
fix Use '--lakehouse-name' instead of '--name'.
deprecated 'fabric login' with username/password (device code) is deprecated. Use service principal or managed identity.
fix Use '--tenant-id', '--client-id', '--client-secret' for SP auth, or '--managed-identity' for Azure resources.
gotcha Workspace names are case-sensitive and must be URL-safe. Spaces are not allowed, but hyphens and underscores are.
fix Use only letters, numbers, hyphens, underscores; avoid spaces.

Authenticate using service principal and create a lakehouse.

# The cli is used from the shell; no Python import needed.
# Authenticate:
import os
os.system('fabric login --tenant-id ' + os.environ.get('FABRIC_TENANT_ID', '') + ' --client-id ' + os.environ.get('FABRIC_CLIENT_ID', '') + ' --client-secret ' + os.environ.get('FABRIC_CLIENT_SECRET', ''))
os.system('fabric lakehouse create --workspace myws --name mylh')