Fabric CLI
Guidance for using fab to programmatically manage Fabric & Power BI service
- Install via
uv tool install ms-fabric-cli (get uv via winget install uv or brew install uv)
- Fabric CLI is for working with the Cloud environment and not local files; it works with Power BI Pro, PPU, or Fabric; you DO NOT need a Fabric SKU to use the Fabric CLI
- Keep
fab current: check the installed version against the latest ms-fabric-cli release and upgrade with uv tool upgrade ms-fabric-cli unless the user has pinned a specific version. Discover commands and flags with fab --help and fab <command> --help rather than hard-coding behavior; the CLI surface changes regularly
[!IMPORTANT]
Any time you encounter errors, user preferences or learnings when using the Fabric cli, ALWAYS note these down in the user memory rules, i.e. .claude/rules/fabric-cli.md for future improvement.
This is ONLY for generic learnings and not for item- or task-specific learnings.
When to use this skill
- Use whenever the user mentions "Fabric" or "Power BI"
- Use when user asks about Power BI workspaces, deployment, tenants, publishing, download, permissions, or data
Critical general rules
- IMPORTANT: The first time you use
fab run check that it is up to date to the latest version (upgrade with uv tool upgrade ms-fabric-cli unless the user has pinned a version) and run fab auth status; If user isn't authenticated, ask them to run fab auth login
- Always use
fab --help and fab <command> --help the first time you use a command to understand its syntax
- You must search the skill /references/ for relevant reference files that explain certain commands, examples, scripts, or workflows before you start using
fab
- Before first use, ask the user if they have Fabric admin access, sensitivity labels or DLP policies, any API restrictions, or preferences for Fabric/Power BI API usage; remind user to add this to memory files
- If workspace or item name is unclear, ask the user first, then verify with
fab ls or fab exists before proceeding
- Ensure that you avoid removing or moving items, workspaces, or definitions, or changing properties without explicit user direction
- If a command is blocked in your permissions and you try to use it, stop and ask the user for clarification; never try to circumvent it
- Create output directories before export:
fab export does not create intermediate directories; mkdir -p the output path first or the command fails with [InvalidPath]
Use -f (force) for non-interactive use
The fab CLI prompts for confirmation, so you you must always append -f to prevent this UNLESS sensitivity labels are enabled, in which case you must ask the user. Do this for the commands:
fab get -q "definition" ; sensitivity label confirmation
fab export ; sensitivity label confirmation
fab import ; overwrite confirmation
fab cp / fab cp -r ; overwrite and sensitivity label confirmation
fab rm ; delete confirmation
fab assign / fab unassign ; capacity/domain assignment confirmation
fab mv ; rename/move confirmation
Quickstart guide
You must read and understand the common list of operations with simple examples
- Check the commands, syntax, and auth status:
fab --help and fab auth status
- Check if the item exists if the user gave the workspace and item name:
fab exists "spaceparts-dev.Workspace/spaceparts-otc-full.SemanticModel"
- Find an item by name across every workspace the user can see:
fab find 'sales' -P type=Report -l (substring on name, description, workspace; -P type= to filter, -l for ids; -q '<jmespath>' for client-side filter/projection). For governance workflows that need last visit / last refresh / owner / storage mode / capacity SKU, use scripts/search_across_workspaces.py; see workspaces.md for the delta.
- Find the workspace:
fab ls
- Find the item:
fab ls "Workspace Name.Workspace"
- Check the commands for that item:
fab desc to get itemTypes
fab desc .<ItemType> for commands i.e. fab desc .SemanticModel
- What's in that item; what's it for; what is it?:
- Full TMDL definition:
fab get "spaceparts-dev.Workspace/spaceparts-otc-full.SemanticModel" -q "definition" -f
- Search a specific measure / table / column:
fab get "ws.Workspace/Model.SemanticModel" -q "definition" -f | rga -i "Sales Amount"
- Retrieve AI instructions / AI schema:
python3 scripts/get_semantic_model_ai_metadata.py "ws.Workspace/Model.SemanticModel" --instructions-out instructions.md --schema-out schema.json
- Get files, tables, or table schemas:
- List lakehouse files:
fab ls "ws.Workspace/LH.Lakehouse/Files"
- List lakehouse tables:
fab ls "ws.Workspace/LH.Lakehouse/Tables"
- Table schema:
fab table schema "ws.Workspace/LH.Lakehouse/Tables/gold/orders"
- Query data (always prefer the wrapper scripts over raw
fab api / duckdb / sqlcmd; they resolve IDs, hosts, and auth for you):
- Semantic model (DAX):
python3 scripts/execute_dax.py "ws.Workspace/Model.SemanticModel" -q "EVALUATE TOPN(10, 'Orders')"
- Lakehouse SQL endpoint, warehouse, or SQL database (T-SQL): prefer the
fabric-sql MCP execute_query(workspaceId, itemId, query) when it is loaded; fall back to python3 scripts/query_sql_endpoint.py "ws.Workspace/LH.Lakehouse" -q "SELECT TOP 10 * FROM dbo.orders". See querying-data.md
- Lakehouse or warehouse Delta over OneLake (DuckDB):
python3 scripts/query_lakehouse_duckdb.py "ws.Workspace/LH.Lakehouse" -q "SELECT * FROM tbl LIMIT 10" -t gold.orders
- Set properties for an item or workspace:
fab set "ws.Workspace/Item.Notebook" -q displayName -i "New Name" or fab set "ws.Workspace" -q description -i "Production environment"
- Review or manage permissions:
- Item ACL:
fab acl ls "ws.Workspace/Model.SemanticModel" then fab acl set "ws.Workspace/Model.SemanticModel" -I user@contoso.com -R Read
- Workspace roles:
fab acl ls "ws.Workspace" then fab acl set "ws.Workspace" -I user@contoso.com -R Member
- Setting up a service principal for automation instead of a human identity: service-principals.md - creation via az CLI, the workspace-role-plus-tenant-setting-group double requirement, and how to authenticate
fab as it
- Deploy items to Fabric:
fab import "ws.Workspace/New.Notebook" -i ./local-path/Nb.Notebook -f
- Download items from Fabric:
fab export "ws.Workspace/Nb.Notebook" -o ./backup -f (always mkdir -p ./backup first)
- Copy or move items between workspaces:
fab cp "dev.Workspace/Item.Notebook" "prod.Workspace" -f or fab mv "ws.Workspace/Old.Notebook" "ws.Workspace/New.Notebook" -f
- Open item in Fabric via browser:
fab open "spaceparts-dev.SpaceParts/Amazing Report.Report"
- Using Fabric or Power BI APIs:
fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes" -X post -i '{"type":"Full"}' or fab api "workspaces/<ws-id>/items"
- Using Azure CLI (advanced) when Fabric CLI doesn't suffice:
- T-SQL over any SQL-capable item ; use
scripts/query_sql_endpoint.py (reuses az login via ActiveDirectoryAzCli; full walkthrough in querying-data.md)
- Pass a Key Vault secret to a consumer without ever reading, echoing, or persisting it:
az login --service-principal -u <appId> -t <tenantId> --password "$(az keyvault secret show --vault-name <vault> --name <secret> --query value -o tsv)" ; command substitution pipes the secret directly into the child process arg list, never stdout, a file, or a named shell variable
- Full fab-vs-az decision matrix: fab-vs-az-cli.md
Essential Concepts
For information about any concepts related to Power BI or Fabric you must search or fetch via the microsoft-learn MCP server (or the pbi-search CLI as an alternative) and ask the user questions with the AskUserQuestion tool; NEVER guess or make assumptions.
Workspaces
- Workspaces are containers for items like Notebooks (and other ETL items), Lakehouses (and other data items), SemanticModels, Reports (and other consumption items), and OrgApps.
- Workspaces can be assigned to different things:
- Deployment Pipelines for lifecycle management (Dev, Test, Prod, etc.)
- Domains for governance and tenant structuring
- Capacities for licensing and resources (Fabric or Premium capacities only; PPU and Pro work differently)
- Git repositories for Source Control via Git integration
Key Patterns
Pay special attention to each of the following areas when using the Fabric CLI
Path Format
Fabric uses filesystem-like paths with type extensions:
"WorkspaceName.Workspace/ItemName.ItemType"
You must quote paths with spaces and punctuation:
"Workspace Name.Workspace/Semantic Model Name.SemanticModel"
For lakehouses this is extended into files and tables:
WorkspaceName.Workspace/LakehouseName.Lakehouse/Files/FileName.extension or /WorkspaceName.Workspace/LakehouseName.Lakehouse/Tables/TableName
For Fabric capacities you have to use fab ls .capacities
Examples:
"Production Workspace.Workspace/Sales Report.Report"
Data.Workspace/MainLH.Lakehouse/Files/data.csv
Data.Workspace/MainLH.Lakehouse/Tables/dbo/customers
Common Item Types
.Workspace - Workspaces
.SemanticModel - Power BI datasets
.Report - Power BI reports
.Notebook - Fabric notebooks
.DataPipeline - Data pipelines
.Lakehouse / .Warehouse/ .SQLDatabase - Data artifacts
.SparkJobDefinition - Spark jobs
.AISkill - Fabric Data Agents
.MirroredDatabase / .MirroredWarehouse - Mirrored databases
.Environment - Spark environments
.UserDataFunction - User data functions
Full list: You must use fab desc or fab desc .<ItemType> to check syntax and types if the user asks about an item type not listed above.
JMESPath Queries
Filter and transform JSON responses with -q:
# Get single field
-q "id"
-q "displayName"
# Get nested field
-q "properties.sqlEndpointProperties"
-q "definition.parts[0]"
# Filter arrays
-q "value[?type=='Lakehouse']"
-q "value[?contains(name, 'prod')]"
# Get first element
-q "value[0]"
-q "definition.parts[?path=='model.tmdl'] | [0]"
Using fab api
fab has an api escape hatch that lets you use any API even if it doesn't have primary commands.
Variable Extraction Pattern
To use fab api you need item IDs. Extract them like this:
WS_ID=$(fab get "ws.Workspace" -q "id" | tr -d '"')
MODEL_ID=$(fab get "ws.Workspace/Model.SemanticModel" -q "id" | tr -d '"')
# Then use in API calls
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes" -X post -i '{"type":"Full"}'
Admin APIs (Requires Admin Role)
Don't use admin commands or APIs if the user doesn't have Admin access. Here's some examples:
# Find semantic models by name (cross-workspace)
fab api "admin/items" -P "type=SemanticModel" -q "itemEntities[?contains(name, 'Sales')]"
# Find all notebooks
fab api "admin/items" -P "type=Notebook" -q "itemEntities[].{name:name,workspace:workspaceId}"
# Find all lakehouses
fab api "admin/items" -P "type=Lakehouse"
# Common types: SemanticModel, Report, Notebook, Lakehouse, Warehouse, DataPipeline, Ontology
For full admin API reference (cross-workspace discovery, tenant settings read/update, capacity/domain/workspace overrides, activity events): admin.md
Error Handling & Debugging
# Show response headers
fab api workspaces --show_headers
# Verbose output
fab get "Production.Workspace/Item" -v
# Save responses for debugging
fab api workspaces -o /tmp/workspaces.json
Common workflows
These are the most common workflows you'll encounter in Fabric
Finding or exploring workspaces, items, or metadata
| Command |
Purpose |
Example |
fab ls |
List workspaces / items |
fab ls "Sales.Workspace" -l |
fab exists |
Check if a path exists |
fab exists "Sales.Workspace/Model.SemanticModel" |
fab get |
Get item details |
fab get "Sales.Workspace" -q "id" |
fab desc |
Supported commands per type |
fab desc .SemanticModel |
Flags:
-l (long listing)
-a (show hidden items)
-q (JMESPath filter)
-v (verbose output)
-o (save response to file)
Fabric discovery follows a drill-down pattern:
- Browsing:
- List workspaces:
fab ls
- List items in a workspace:
fab ls "ws.Workspace" -l
- Confirm a path exists:
fab exists "ws.Workspace/Item"
- Check what commands an item type supports:
fab desc .<ItemType>
- Inspection:
- Get item details:
fab get "ws.Workspace/Item"
- Pull a single field:
fab get "ws.Workspace" -q "id"
- Cross-workspace search:
Check references before exploring:
Querying data
| Command |
Purpose |
Example |
fab get -q "definition" |
Get model schema |
fab get "ws.Workspace/Model.SemanticModel" -q "definition" -f |
fab api -A powerbi |
Execute DAX |
fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/executeQueries" -X post -i '{"queries":[{"query":"EVALUATE..."}]}' |
fab ls |
Browse files / tables |
fab ls "ws.Workspace/LH.Lakehouse/Files" |
fab table schema |
Lakehouse table schema |
fab table schema "ws.Workspace/LH.Lakehouse/Tables/sales" |
fab cp |
Upload / download OneLake file |
fab cp ./local.csv "ws.Workspace/LH.Lakehouse/Files/" |
duckdb + delta_scan |
Query Delta tables (requires DuckDB) |
duckdb -c "... delta_scan('abfss://<ws-id>@onelake.../<lh-id>/Tables/schema/table')" |
duckdb + read_csv/json |
Query raw files (requires DuckDB) |
duckdb -c "... read_csv('abfss://.../Files/data.csv')" |
Flags:
-A fabric|powerbi|storage|azure (API audience)
-X get|post|put|delete|patch (HTTP method)
-i (JSON body or file)
-f (skip sensitivity prompt on definition pulls).
Fabric exposes three query paths depending on the source; always prefer the wrapper scripts -- they resolve IDs, hosts, and auth for you:
- Semantic models (DAX):
- Find model fields first:
fab get "ws.Workspace/Model.SemanticModel" -q "definition"
- Query:
scripts/execute_dax.py
- Lakehouses / Warehouses via Delta over OneLake (DuckDB):
- Lakehouse SQL endpoint, Warehouse, or SQL Database (T-SQL):
- Prefer the
fabric-sql MCP execute_query(workspaceId, itemId, query) when loaded; server-side, no local tooling
- Fall back to
scripts/query_sql_endpoint.py (sqlcmd; auto-detects host per item type, reuses az login via ActiveDirectoryAzCli) when the MCP is unavailable
- Prefer either over DuckDB when you need
INFORMATION_SCHEMA, sys.* metadata, CTEs, or window functions
- Full route priority: querying-data.md
Check references before writing queries:
Changing metadata or access (descriptions, tags, endorsement, properties, bindings, permissions)
| Command |
Purpose |
Example |
fab set |
Update property |
fab set "ws.Workspace/Item" -q displayName -i "New Name" |
fab mv |
Rename / move item |
fab mv "ws/Old.Notebook" "ws/New.Notebook" -f |
fab acl ls |
List permissions |
fab acl ls "ws.Workspace" |
fab acl set |
Grant permission |
fab acl set "ws.Workspace" -I <objectId> -R Member |
fab acl rm |
Revoke permission |
fab acl rm "ws.Workspace" -I <upn> |
fab label set |
Set sensitivity label |
fab label set "ws/Nb.Notebook" --name Confidential |
Flags:
-q <field> + -i <value> (set a single property)
-I (object ID or UPN for fab acl)
-R Admin|Member|Contributor|Viewer (role for fab acl set)
-f (skip confirmation; ask user first if sensitivity labels are in play)
Metadata and access changes fall into a few groups:
- Properties (displayName, description, sensitivity config):
- Native update:
fab set "<path>" -q <field> -i "<value>"
- Capture current state first so you can revert:
fab get -v -o /tmp/before.json
- Endorsement, certification, and tags (no first-class
fab commands):
- Patch via
fab api with item-specific endpoints
- Tag workflow: tags.md
- Endorsement patterns: reference.md
- Folder placement:
- Move items between workspace subfolders: folders.md
- Access control and sensitivity labels:
- Grant / revoke:
fab acl set, fab acl rm
- Set sensitivity label:
fab label set
- Verify the principal first:
az ad user show
- Never change permissions or labels without explicit user confirmation
- Bindings:
Check references before changing metadata:
Working with workspaces
| Command |
Purpose |
Example |
fab mkdir |
Create workspace / item |
fab mkdir "New.Workspace" -P capacityname=MyCapacity |
fab assign |
Attach capacity / domain |
fab assign .capacities/cap.Capacity -W ws.Workspace -f |
fab unassign |
Detach capacity / domain |
fab unassign .capacities/cap.Capacity -W ws.Workspace |
fab start / fab stop |
Resume / pause capacity |
fab start .capacities/cap.Capacity |
fab cp -r |
Fork workspace |
fab cp "dev.Workspace" "prod.Workspace" -r -f |
fab rm |
Soft-delete (see recovery) |
fab rm "ws/Item.Type" -f |
Flags:
-P key=value (creation params for fab mkdir)
-W (target workspace for fab assign / fab unassign)
-r (recursive copy/move)
-bpc (block on path collision for fab cp)
-f (skip confirmation)
Workspace-scope operations fall into a few groups:
- Create and provision:
- Create workspace:
fab mkdir "<Name>.Workspace" -P capacityname=<cap>
- Attach capacity or domain:
fab assign .capacities/<cap>.Capacity -W <ws>.Workspace
- Planning context, create/get/set surface, large storage format, Spark pools, OneLake defaults, Git: workspaces.md
- Copy, fork, download:
- Duplicate a workspace in-tenant:
fab cp -r "dev.Workspace" "prod.Workspace"
- Dry-run the source tree first:
fab ls "dev.Workspace"
- Full local snapshot (items + lakehouse files):
scripts/download_workspace.py
- Permissions:
- Inspect / grant / revoke:
fab acl ls | set | rm
- Tenant-wide governance audit: use the
audit-tenant-settings skill from the fabric-admin plugin
- Connections and gateways (bound to, but outside, the workspace):
- Credential types (WorkspaceIdentity, SPN, Basic), OAuth2 limits: connections.md
- Datasource binding, credential rotation: gateways.md
- Folders inside a workspace:
Check references before modifying workspaces:
Executing or scheduling jobs (notebooks, notebook cells, pipelines, semantic model refresh)
| Command |
Purpose |
Example |
fab job run |
Run synchronously |
fab job run "ws/ETL.Notebook" -P date:string=2025-01-01 |
fab job start |
Run asynchronously |
fab job start "ws/ETL.Notebook" |
fab job run-list |
List executions |
fab job run-list "ws/Nb.Notebook" |
fab job run-status |
Check status |
fab job run-status "ws/Nb.Notebook" --id <job-id> |
fab job run-cancel |
Cancel a job |
fab job run-cancel "ws/Nb.Notebook" --id <job-id> -w |
scripts/run_notebook_checked.py |
Run a notebook + verify its exit value (status Completed ≠ ETL succeeded) |
python3 scripts/run_notebook_checked.py "ws/ETL.Notebook" |
fab api -A powerbi .../refreshes |
Trigger semantic model refresh |
fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes" -X post -i '{"type":"Full"}' |
Flags:
-P key:type=value (parameters, type is string|int|bool)
--id (job run ID)
-w (wait on cancel)
--timeout (overall timeout for synchronous runs)
--polling_interval (status poll cadence)
Jobs map to different endpoints depending on item type:
- Notebooks and pipelines:
- Run synchronously:
fab job run "ws/ETL.Notebook" -P date:string=2025-01-01
- Run asynchronously:
fab job start "ws/ETL.Notebook"
- Check status:
fab job run-status "ws/Nb.Notebook" --id <job-id>
- List history:
fab job run-list "ws/Nb.Notebook"
- Verify the REAL outcome: a job
Completed only means the process finished -- a notebook can catch its own exception and exit a failure payload while still showing Completed. Read its exit value, or use scripts/run_notebook_checked.py; details in notebooks.md
- Python / PySpark kernels, Livy sessions, cell-level CRUD: notebooks.md
- Semantic model refresh (not exposed as
fab job):
- Trigger:
fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes" -X post -i '{"type":"Full"}'
- Check current run before starting a new one (409 if already running):
fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes?\$top=1"
- Enhanced refresh, incremental policies, partition targeting: semantic-models.md
- Dataflow refresh:
- Scheduling:
Check references before running jobs:
Fabric admin operations (auditing, management)
| Command |
Purpose |
Example |
fab api "admin/items" |
Cross-workspace item search |
fab api "admin/items" -P "type=SemanticModel" -q "itemEntities[?contains(name,'Sales')]" |
fab api "admin/workspaces" |
Workspace inventory |
fab api "admin/workspaces" |
fab api "admin/tenantsettings" |
Tenant settings |
fab api "admin/tenantsettings" |
fab api "admin/capacities" |
Capacity inventory |
fab api "admin/capacities" |
fab api -X post .../update |
Update tenant setting |
fab api -X post "admin/tenantsettings/<name>/update" -i body.json |
Flags:
-P key=value (query params, e.g. type=SemanticModel)
-q (JMESPath filter)
-X post + -i (write ops)
--show_headers (inspect Retry-After on 429)
Admin-scope work is gated behind the Fabric / Power BI admin role. Confirm access first with fab api "admin/capacities" 2>&1 | head -5; if it errors, stop rather than retry.
Two entry points cover most admin tasks:
- Governance audits (tenant settings, delegated overrides, Entra SG scoping):
- Use the
audit-tenant-settings skill from the fabric-admin plugin. It owns the curated metadata baseline, the audit + change-detection script, delegated-override enumeration, and the Entra SG investigation workflow.
- Invoke it whenever the question combines tenant posture with group membership, override scope, or drift against the baseline.
- Raw admin APIs (cross-workspace search, activity events, artifact access, item search):
- Patterns in admin.md
- Rate limit: 25 write requests / minute; honor
Retry-After on 429
- Print the exact command and wait for user confirmation before any destructive admin operation
Check references before admin work:
Definitions and deployment (item definitions, deployment pipelines, git integration, cicd)
| Command |
Purpose |
Example |
fab get -q "definition" |
Read raw definition |
fab get "ws/Model.SemanticModel" -q "definition" -f |
fab export |
Export item to local |
fab export "ws/Nb.Notebook" -o ./backup -f |
fab import |
Import item from local |
fab import "ws/Nb.Notebook" -i ./backup/Nb.Notebook -f |
fab cp |
Copy between workspaces |
fab cp "dev/Item" "prod.Workspace" -f |
fab api "deploymentPipelines" |
Deployment pipelines API |
fab api "deploymentPipelines" -q "value[]" |
Flags:
-o (output path for fab export)
-i (input path or JSON body for fab import)
--format (definition format for export / import)
-f (skip overwrite and sensitivity prompts)
[!IMPORTANT]
The poll interval is by far the biggest performance lever for any definition change.
Creating or updating an item definition is a long-running operation (LRO): the API returns
202 Accepted with a Retry-After: 20 header. fab import, nb create, and nb cell edit
wait roughly that long between status polls, so a notebook that the server finishes in ~1s
takes them 25-60s. Neither fab nor nb exposes a knob to change that interval.
For notebook definition changes, strongly prefer scripts/deploy_notebook.py,
which polls the LRO every ~0.3s (tunable via --poll-interval) and creates in ~1-2s or updates
in place in ~1s. Auto-detects create vs update. When you must roll your own for another item
type, the rule is the same: poll updateDefinition / create at ~0.3s, not the advertised 20s.
python3 scripts/deploy_notebook.py "ws.Workspace/ETL.Notebook" -i ./ETL.Notebook # create or update in place
Every Fabric item has a serializable definition. Move definitions between environments depending on scope:
- Single item:
- Round-trip locally:
fab export then fab import (always mkdir -p the output directory first; fab export does not create intermediate directories and fails with [InvalidPath])
- Same-tenant shortcut, no local hop:
fab cp "dev/Item" "prod.Workspace"
- Semantic model as PBIP (TMDL + blank report):
- Export the model with
fab export, create the report with pbir new report, then combine
them with pbir report merge-to-thick; see import-download-deploy.md
- Full workspace snapshot (items + lakehouse files):
- Promotion between Dev, Test, Prod:
- Fabric deployment pipelines API (covers all item types)
- Power BI pipelines API (Power BI items only, but finer-grained deploy flags like
allowPurgeData, allowTakeOver)
- When to use each, selective deploy, LRO polling: deployment-pipelines.md
- Git integration (connect workspace to repo, branch, commit, update from git):
Check references before deploying:
Related skills
audit-tenant-settings (in the fabric-admin plugin) ; Fabric governance workflow covering tenant settings, delegated overrides (capacity / domain / workspace), and the Entra security groups those settings reference. Read-only; holds the curated metadata baseline and the audit + change-detection script.
Gotchas
- IMPORTANT: DON'T try to use
fab ls on items that aren't data items (.Lakehouse, .Warehouse, etc); use fab ls to find workspaces and items, and use fab get to look at definitions
- ALWAYS Use the
-f flag when using fab get, fab import, fab export, etc. as described above
- ONLY fallback to
fab api when a command doesn't exist
- Definition changes feel slow but aren't:
fab import / nb create / nb cell edit take 25-60s to push a notebook definition only because they poll the LRO at the server's Retry-After: 20. The work is ~1s. Use scripts/deploy_notebook.py (tight-polls at ~0.3s) for definition changes; the poll interval is the single biggest lever
References
Reference map (which references cluster together; follow the links between them, not just this list):
etl / notebooks
notebooks.md ── run jobs, exit value, scheduling
├─ querying-data.md ── nb exec / Livy, DuckDB/sqlcmd, SQL-endpoint sync
└─ lakehouses.md ── attach, table ops, OneLake shortcuts, SQL-endpoint id
(cross-plugin) executing-spark, using-duckdb ── etl plugin: ephemeral Spark, local Delta
data items
lakehouses.md · warehouses.md · sql-databases.md · semantic-models.md
└─ all feed querying-data.md (route priority) and notebooks.md (load then read)
governance / deploy
admin.md · permissions.md · tags.md · folders.md
import-download-deploy.md ─ deployment-pipelines.md ─ workspaces.md (git status)
(cross-plugin) audit-tenant-settings ── fabric-admin plugin
Skill references:
- Import, Download, and Deploy - Export / import / copy / move items, PBIP round-trips, dev-to-prod migration patterns
- Querying Data - Query semantic models in DAX and lakehouses or warehouses in SQL with DuckDB
- Lakehouses - Endpoints, file/table operations, OneLake paths
- Warehouses - Create, browse, query via DuckDB, load data
- SQL Databases - Create, browse, query via DuckDB, auto-mirroring
- Semantic Models - TMDL, DAX, refresh, storage mode
- Reports - Export, import, visuals, fields
- Paginated Reports - RDL upload, export-to-file, datasources, parameters
- Notebooks - Python/PySpark kernels, metadata, cell CRUD, Livy execution, scheduling
- Workspaces - Create, manage, permissions
- Permissions - Sharing and distribution, workspace roles, item permissions, apps, embed, B2B, deployment pipeline permissions, licensing and capacity SKUs
- Deployment Pipelines - CI/CD, deploy stages, selective deploy, LRO polling
- Dataflows - Gen1 and Gen2, refresh, publish, admin
- Dashboards - Tiles, clone (dashboards are not reports)
- Org Apps - Read-only API for distributed content packages
- Scorecards - Goals, check-ins, status rules (Preview API)
- Gateways - Datasources, credentials, dataset binding
- Folders - Organize items into folders via API; includes best practices for structuring workspaces
- Tags - Create, apply, and audit tenant/domain tags on items and workspaces via
fab api (no native fab tag command)
- fab vs az CLI - When to use which; capacity, networking, Key Vault, monitoring, CMK, CI/CD
- Admin APIs - Cross-workspace search, tenant operations, governance
- API Reference - Capacities, domains, misc API patterns
- Connections - Create, update, list connections programmatically; credential types (WorkspaceIdentity, SPN, Basic); OAuth2 limitations
- Service Principals - Create an SP with az CLI, grant it workspace access, clear the tenant-setting gate, authenticate
fab as it (real login vs env-token testing), rotation and teardown
- Full Command Reference - All commands detailed
Scripts (scripts that you can execute):
- search_across_workspaces.py ; cross-workspace governance complement to
fab find (last visit, last refresh, owner, storage mode, capacity SKU, Copilot readiness); see workspaces.md for when to choose which
- get-downstream-reports.py ; find all reports connected to a given semantic model across accessible workspaces (no admin required)
- execute_dax.py ; execute DAX queries against semantic models; output as table, csv, or json
- query_lakehouse_duckdb.py ; query lakehouse or warehouse Delta tables via DuckDB against OneLake (reuses
az login); output as table, csv, or json
- query_sql_endpoint.py ; query lakehouse SQL endpoint, warehouse, or SQL database via
sqlcmd (reuses az login through ActiveDirectoryAzCli); output as table, csv, or json
- create_direct_lake_model.py ; create a Direct Lake semantic model from lakehouse tables
- download_workspace.py ; download a full workspace with all item definitions and lakehouse files
- run_notebook_checked.py ; run a notebook and check its exit value, exiting non-zero when the notebook's own
{ok:false} verdict fails despite a Completed job status (reads the exit value via the notebook job-instance beta endpoint)
- deploy_notebook.py ; create or update a notebook definition fast (~1-2s) by tight-polling the LRO instead of the CLI's ~20s
Retry-After cadence; auto-detects create vs update, --poll-interval is the performance lever. Strongly prefer this over fab import / nb for any notebook definition change
See scripts/README.md for detailed usage, arguments, and examples. Always search the scripts/ folder before writing a new helper; a script may already exist for the task.
External references (request markdown when possible):
Source: data-goblin/power-bi-agentic-development → plugins/fabric-cli/skills/fabric-cli/SKILL.md
1---2name: fabric-cli3description: Expert guidance for using the Fabric CLI (`fab`) to fully interact with Fabric workspaces, items, and configuration. Automatically invoke this skill whenever the user mentions "Fabric" or "Power BI Service" or a "Fabric/Power BI workspace".4---5# Fabric CLI
6
7Guidance for using `fab` to programmatically manage Fabric & Power BI service
8
9- Install via `uv tool install ms-fabric-cli` (get `uv` via `winget install uv` or `brew install uv`)
10- Fabric CLI is for working with the Cloud environment and not local files; it works with Power BI Pro, PPU, or Fabric; you DO NOT need a Fabric SKU to use the Fabric CLI
11- Keep `fab` current: check the installed version against the latest `ms-fabric-cli` release and upgrade with `uv tool upgrade ms-fabric-cli` unless the user has pinned a specific version. Discover commands and flags with `fab --help` and `fab <command> --help` rather than hard-coding behavior; the CLI surface changes regularly
12
13> [!IMPORTANT]
14> Any time you encounter errors, user preferences or learnings when using the Fabric cli, ALWAYS note these down in the user memory rules, i.e. `.claude/rules/fabric-cli.md` for future improvement.
15> This is ONLY for generic learnings and not for item- or task-specific learnings.
16
17## When to use this skill
18
19- Use whenever the user mentions "Fabric" or "Power BI"
20- Use when user asks about Power BI workspaces, deployment, tenants, publishing, download, permissions, or data
21
22
23## Critical general rules
24
25- IMPORTANT: The first time you use `fab` run check that it is up to date to the latest version (upgrade with `uv tool upgrade ms-fabric-cli` unless the user has pinned a version) and run `fab auth status`; If user isn't authenticated, ask them to run `fab auth login`
26- Always use `fab --help` and `fab <command> --help` the first time you use a command to understand its syntax
27- You must search the skill /references/ for relevant reference files that explain certain commands, examples, scripts, or workflows before you start using `fab`
28- Before first use, ask the user if they have Fabric admin access, sensitivity labels or DLP policies, any API restrictions, or preferences for Fabric/Power BI API usage; remind user to add this to memory files
29- If workspace or item name is unclear, ask the user first, then verify with `fab ls` or `fab exists` before proceeding
30- Ensure that you avoid removing or moving items, workspaces, or definitions, or changing properties without explicit user direction
31- If a command is blocked in your permissions and you try to use it, stop and ask the user for clarification; never try to circumvent it
32- Create output directories before export: `fab export` does not create intermediate directories; `mkdir -p` the output path first or the command fails with `[InvalidPath]`
33
34
35### Use `-f` (force) for non-interactive use
36
37The `fab` CLI prompts for confirmation, so you **you must always append `-f`** to prevent this UNLESS sensitivity labels are enabled, in which case you must ask the user. Do this for the commands:
38
39- `fab get -q "definition"` ; sensitivity label confirmation
40- `fab export` ; sensitivity label confirmation
41- `fab import` ; overwrite confirmation
42- `fab cp` / `fab cp -r` ; overwrite and sensitivity label confirmation
43- `fab rm` ; delete confirmation
44- `fab assign` / `fab unassign` ; capacity/domain assignment confirmation
45- `fab mv` ; rename/move confirmation
46
47
48## Quickstart guide
49
50You must read and understand the common list of operations with simple examples
51
520. Check the commands, syntax, and auth status: `fab --help` and `fab auth status`
531. Check if the item exists if the user gave the workspace and item name: `fab exists "spaceparts-dev.Workspace/spaceparts-otc-full.SemanticModel"`
542. Find an item by name across every workspace the user can see: `fab find 'sales' -P type=Report -l` (substring on name, description, workspace; `-P type=` to filter, `-l` for ids; `-q '<jmespath>'` for client-side filter/projection). For governance workflows that need last visit / last refresh / owner / storage mode / capacity SKU, use [`scripts/search_across_workspaces.py`](./scripts/search_across_workspaces.py); see [workspaces.md](./references/workspaces.md#cross-workspace-search) for the delta.
553. Find the workspace: `fab ls`
564. Find the item: `fab ls "Workspace Name.Workspace"`
574. Check the commands for that item:
58 - `fab desc` to get itemTypes
59 - `fab desc .<ItemType>` for commands i.e. `fab desc .SemanticModel`
605. What's in that item; what's it for; what is it?:
61 - Full TMDL definition: `fab get "spaceparts-dev.Workspace/spaceparts-otc-full.SemanticModel" -q "definition" -f`
62 - Search a specific measure / table / column: `fab get "ws.Workspace/Model.SemanticModel" -q "definition" -f | rga -i "Sales Amount"`
63 - Retrieve AI instructions / AI schema: `python3 scripts/get_semantic_model_ai_metadata.py "ws.Workspace/Model.SemanticModel" --instructions-out instructions.md --schema-out schema.json`
646. Get files, tables, or table schemas:
65 - List lakehouse files: `fab ls "ws.Workspace/LH.Lakehouse/Files"`
66 - List lakehouse tables: `fab ls "ws.Workspace/LH.Lakehouse/Tables"`
67 - Table schema: `fab table schema "ws.Workspace/LH.Lakehouse/Tables/gold/orders"`
687. Query data (always prefer the wrapper scripts over raw `fab api` / `duckdb` / `sqlcmd`; they resolve IDs, hosts, and auth for you):
69 - Semantic model (DAX): `python3 scripts/execute_dax.py "ws.Workspace/Model.SemanticModel" -q "EVALUATE TOPN(10, 'Orders')"`
70 - Lakehouse SQL endpoint, warehouse, or SQL database (T-SQL): prefer the `fabric-sql` MCP `execute_query(workspaceId, itemId, query)` when it is loaded; fall back to `python3 scripts/query_sql_endpoint.py "ws.Workspace/LH.Lakehouse" -q "SELECT TOP 10 * FROM dbo.orders"`. See [querying-data.md](./references/querying-data.md#querying-the-sql-endpoint-route-priority)
71 - Lakehouse or warehouse Delta over OneLake (DuckDB): `python3 scripts/query_lakehouse_duckdb.py "ws.Workspace/LH.Lakehouse" -q "SELECT * FROM tbl LIMIT 10" -t gold.orders`
728. Set properties for an item or workspace: `fab set "ws.Workspace/Item.Notebook" -q displayName -i "New Name"` or `fab set "ws.Workspace" -q description -i "Production environment"`
739. Review or manage permissions:
74 - Item ACL: `fab acl ls "ws.Workspace/Model.SemanticModel"` then `fab acl set "ws.Workspace/Model.SemanticModel" -I user@contoso.com -R Read`
75 - Workspace roles: `fab acl ls "ws.Workspace"` then `fab acl set "ws.Workspace" -I user@contoso.com -R Member`
76 - Setting up a service principal for automation instead of a human identity: [service-principals.md](./references/service-principals.md) - creation via az CLI, the workspace-role-plus-tenant-setting-group double requirement, and how to authenticate `fab` as it
7710. Deploy items to Fabric: `fab import "ws.Workspace/New.Notebook" -i ./local-path/Nb.Notebook -f`
7811. Download items from Fabric: `fab export "ws.Workspace/Nb.Notebook" -o ./backup -f` (always `mkdir -p ./backup` first)
7912. Copy or move items between workspaces: `fab cp "dev.Workspace/Item.Notebook" "prod.Workspace" -f` or `fab mv "ws.Workspace/Old.Notebook" "ws.Workspace/New.Notebook" -f`
8013. Open item in Fabric via browser: `fab open "spaceparts-dev.SpaceParts/Amazing Report.Report"`
8114. Using Fabric or Power BI APIs: `fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes" -X post -i '{"type":"Full"}'` or `fab api "workspaces/<ws-id>/items"`
8215. Using [Azure CLI](./references/fab-vs-az-cli.md) (advanced) when Fabric CLI doesn't suffice:
83 - T-SQL over any SQL-capable item ; use [`scripts/query_sql_endpoint.py`](./scripts/query_sql_endpoint.py) (reuses `az login` via `ActiveDirectoryAzCli`; full walkthrough in [querying-data.md](./references/querying-data.md#sqlcmd-over-lakehouse-warehouse-and-sql-database))
84 - Pass a Key Vault secret to a consumer without ever reading, echoing, or persisting it: `az login --service-principal -u <appId> -t <tenantId> --password "$(az keyvault secret show --vault-name <vault> --name <secret> --query value -o tsv)"` ; command substitution pipes the secret directly into the child process arg list, never stdout, a file, or a named shell variable
85 - Full fab-vs-az decision matrix: [fab-vs-az-cli.md](./references/fab-vs-az-cli.md)
86
87
88## Essential Concepts
89
90For information about any concepts related to Power BI or Fabric you must search or fetch via the `microsoft-learn` MCP server (or the `pbi-search` CLI as an alternative) and ask the user questions with the `AskUserQuestion` tool; NEVER guess or make assumptions.
91
92### Workspaces
93
94- **Workspaces** are containers for **items** like Notebooks (and other ETL items), Lakehouses (and other data items), SemanticModels, Reports (and other consumption items), and OrgApps.
95- Workspaces can be assigned to different things:
96 - Deployment Pipelines for lifecycle management (Dev, Test, Prod, etc.)
97 - Domains for governance and tenant structuring
98 - Capacities for licensing and resources (Fabric or Premium capacities only; PPU and Pro work differently)
99 - Git repositories for Source Control via Git integration
100
101
102## Key Patterns
103
104Pay special attention to each of the following areas when using the Fabric CLI
105
106
107### Path Format
108
109Fabric uses filesystem-like paths with type extensions:
110
111`"WorkspaceName.Workspace/ItemName.ItemType"`
112
113You must quote paths with spaces and punctuation:
114
115`"Workspace Name.Workspace/Semantic Model Name.SemanticModel"`
116
117For lakehouses this is extended into files and tables:
118
119`WorkspaceName.Workspace/LakehouseName.Lakehouse/Files/FileName.extension` or `/WorkspaceName.Workspace/LakehouseName.Lakehouse/Tables/TableName`
120
121For Fabric capacities you have to use `fab ls .capacities`
122
123Examples:
124
125- `"Production Workspace.Workspace/Sales Report.Report"`
126- `Data.Workspace/MainLH.Lakehouse/Files/data.csv`
127- `Data.Workspace/MainLH.Lakehouse/Tables/dbo/customers`
128
129
130### Common Item Types
131
132- `.Workspace` - Workspaces
133- `.SemanticModel` - Power BI datasets
134- `.Report` - Power BI reports
135- `.Notebook` - Fabric notebooks
136- `.DataPipeline` - Data pipelines
137- `.Lakehouse` / `.Warehouse`/ `.SQLDatabase` - Data artifacts
138- `.SparkJobDefinition` - Spark jobs
139- `.AISkill` - Fabric Data Agents
140- `.MirroredDatabase` / `.MirroredWarehouse` - Mirrored databases
141- `.Environment` - Spark environments
142- `.UserDataFunction` - User data functions
143
144Full list: You must use `fab desc` or `fab desc .<ItemType>` to check syntax and types if the user asks about an item type not listed above.
145
146
147### JMESPath Queries
148
149Filter and transform JSON responses with `-q`:
150
151```bash
152# Get single field
153-q "id"
154-q "displayName"
155
156# Get nested field
157-q "properties.sqlEndpointProperties"
158-q "definition.parts[0]"
159
160# Filter arrays
161-q "value[?type=='Lakehouse']"
162-q "value[?contains(name, 'prod')]"
163
164# Get first element
165-q "value[0]"
166-q "definition.parts[?path=='model.tmdl'] | [0]"
167```
168
169### Using `fab api`
170
171`fab` has an api escape hatch that lets you use any API even if it doesn't have primary commands.
172
173
174#### Variable Extraction Pattern
175
176To use `fab api` you need item IDs. Extract them like this:
177
178```bash
179WS_ID=$(fab get "ws.Workspace" -q "id" | tr -d '"')
180MODEL_ID=$(fab get "ws.Workspace/Model.SemanticModel" -q "id" | tr -d '"')
181
182# Then use in API calls
183fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes" -X post -i '{"type":"Full"}'
184```
185
186
187#### Admin APIs (Requires Admin Role)
188
189Don't use admin commands or APIs if the user doesn't have Admin access. Here's some examples:
190
191```bash
192# Find semantic models by name (cross-workspace)
193fab api "admin/items" -P "type=SemanticModel" -q "itemEntities[?contains(name, 'Sales')]"
194
195# Find all notebooks
196fab api "admin/items" -P "type=Notebook" -q "itemEntities[].{name:name,workspace:workspaceId}"
197
198# Find all lakehouses
199fab api "admin/items" -P "type=Lakehouse"
200
201# Common types: SemanticModel, Report, Notebook, Lakehouse, Warehouse, DataPipeline, Ontology
202```
203
204For full admin API reference (cross-workspace discovery, tenant settings read/update, capacity/domain/workspace overrides, activity events): [admin.md](./references/admin.md)
205
206
207### Error Handling & Debugging
208
209```bash
210# Show response headers
211fab api workspaces --show_headers
212
213# Verbose output
214fab get "Production.Workspace/Item" -v
215
216# Save responses for debugging
217fab api workspaces -o /tmp/workspaces.json
218```
219
220
221## Common workflows
222
223These are the most common workflows you'll encounter in Fabric
224
225### Finding or exploring workspaces, items, or metadata
226
227| Command | Purpose | Example |
228|---|---|---|
229| `fab ls` | List workspaces / items | `fab ls "Sales.Workspace" -l` |
230| `fab exists` | Check if a path exists | `fab exists "Sales.Workspace/Model.SemanticModel"` |
231| `fab get` | Get item details | `fab get "Sales.Workspace" -q "id"` |
232| `fab desc` | Supported commands per type | `fab desc .SemanticModel` |
233
234Flags:
235- `-l` (long listing)
236- `-a` (show hidden items)
237- `-q` (JMESPath filter)
238- `-v` (verbose output)
239- `-o` (save response to file)
240
241Fabric discovery follows a drill-down pattern:
242
243- Browsing:
244 - List workspaces: `fab ls`
245 - List items in a workspace: `fab ls "ws.Workspace" -l`
246 - Confirm a path exists: `fab exists "ws.Workspace/Item"`
247 - Check what commands an item type supports: `fab desc .<ItemType>`
248- Inspection:
249 - Get item details: `fab get "ws.Workspace/Item"`
250 - Pull a single field: `fab get "ws.Workspace" -q "id"`
251- Cross-workspace search:
252 - Routine search across name, description, workspace: `fab find '<text>' -P type=<Type> -l`
253 - Governance fields not in `fab find` (last visit, last refresh, owner, storage mode, capacity SKU, Copilot readiness): [`scripts/search_across_workspaces.py`](./scripts/search_across_workspaces.py); see [workspaces.md](./references/workspaces.md#cross-workspace-search) for the delta
254 - Downstream reports for a given model: [`scripts/get-downstream-reports.py`](./scripts/get-downstream-reports.py)
255 - Tenant-wide admin APIs: [admin.md](./references/admin.md)
256
257Check references before exploring:
258
259- [workspaces.md](./references/workspaces.md)
260- [folders.md](./references/folders.md)
261- [admin.md](./references/admin.md)
262- [reference.md](./references/reference.md)
263
264
265### Querying data
266
267| Command | Purpose | Example |
268|---|---|---|
269| `fab get -q "definition"` | Get model schema | `fab get "ws.Workspace/Model.SemanticModel" -q "definition" -f` |
270| `fab api -A powerbi` | Execute DAX | `fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/executeQueries" -X post -i '{"queries":[{"query":"EVALUATE..."}]}'` |
271| `fab ls` | Browse files / tables | `fab ls "ws.Workspace/LH.Lakehouse/Files"` |
272| `fab table schema` | Lakehouse table schema | `fab table schema "ws.Workspace/LH.Lakehouse/Tables/sales"` |
273| `fab cp` | Upload / download OneLake file | `fab cp ./local.csv "ws.Workspace/LH.Lakehouse/Files/"` |
274| `duckdb` + `delta_scan` | Query Delta tables (requires DuckDB) | `duckdb -c "... delta_scan('abfss://<ws-id>@onelake.../<lh-id>/Tables/schema/table')"` |
275| `duckdb` + `read_csv/json` | Query raw files (requires DuckDB) | `duckdb -c "... read_csv('abfss://.../Files/data.csv')"` |
276
277Flags:
278- `-A fabric|powerbi|storage|azure` (API audience)
279- `-X get|post|put|delete|patch` (HTTP method)
280- `-i` (JSON body or file)
281- `-f` (skip sensitivity prompt on definition pulls).
282
283Fabric exposes three query paths depending on the source; always prefer the wrapper scripts -- they resolve IDs, hosts, and auth for you:
284
285- Semantic models (DAX):
286 - Find model fields first: `fab get "ws.Workspace/Model.SemanticModel" -q "definition"`
287 - Query: [`scripts/execute_dax.py`](./scripts/execute_dax.py)
288- Lakehouses / Warehouses via Delta over OneLake (DuckDB):
289 - Query a single table: [`scripts/query_lakehouse_duckdb.py`](./scripts/query_lakehouse_duckdb.py) (use `tbl` as a placeholder and pass `-t schema.table`)
290 - Multi-table joins or raw files in `Files/`: pass `--sql` with your own `delta_scan()` / `read_csv` / `read_json_auto` calls
291 - Optionally scaffold a Direct Lake model instead: [`scripts/create_direct_lake_model.py`](./scripts/create_direct_lake_model.py)
292- Lakehouse SQL endpoint, Warehouse, or SQL Database (T-SQL):
293 - Prefer the `fabric-sql` MCP `execute_query(workspaceId, itemId, query)` when loaded; server-side, no local tooling
294 - Fall back to [`scripts/query_sql_endpoint.py`](./scripts/query_sql_endpoint.py) (`sqlcmd`; auto-detects host per item type, reuses `az login` via `ActiveDirectoryAzCli`) when the MCP is unavailable
295 - Prefer either over DuckDB when you need `INFORMATION_SCHEMA`, `sys.*` metadata, CTEs, or window functions
296 - Full route priority: [querying-data.md](./references/querying-data.md#querying-the-sql-endpoint-route-priority)
297
298Check references before writing queries:
299
300- [querying-data.md](./references/querying-data.md)
301- [semantic-models.md](./references/semantic-models.md)
302- [lakehouses.md](./references/lakehouses.md)
303- [warehouses.md](./references/warehouses.md)
304- [sql-databases.md](./references/sql-databases.md)
305
306
307### Changing metadata or access (descriptions, tags, endorsement, properties, bindings, permissions)
308
309| Command | Purpose | Example |
310|---|---|---|
311| `fab set` | Update property | `fab set "ws.Workspace/Item" -q displayName -i "New Name"` |
312| `fab mv` | Rename / move item | `fab mv "ws/Old.Notebook" "ws/New.Notebook" -f` |
313| `fab acl ls` | List permissions | `fab acl ls "ws.Workspace"` |
314| `fab acl set` | Grant permission | `fab acl set "ws.Workspace" -I <objectId> -R Member` |
315| `fab acl rm` | Revoke permission | `fab acl rm "ws.Workspace" -I <upn>` |
316| `fab label set` | Set sensitivity label | `fab label set "ws/Nb.Notebook" --name Confidential` |
317
318Flags:
319- `-q <field>` + `-i <value>` (set a single property)
320- `-I` (object ID or UPN for `fab acl`)
321- `-R Admin|Member|Contributor|Viewer` (role for `fab acl set`)
322- `-f` (skip confirmation; ask user first if sensitivity labels are in play)
323
324Metadata and access changes fall into a few groups:
325
326- Properties (displayName, description, sensitivity config):
327 - Native update: `fab set "<path>" -q <field> -i "<value>"`
328 - Capture current state first so you can revert: `fab get -v -o /tmp/before.json`
329- Endorsement, certification, and tags (no first-class `fab` commands):
330 - Patch via `fab api` with item-specific endpoints
331 - Tag workflow: [tags.md](./references/tags.md)
332 - Endorsement patterns: [reference.md](./references/reference.md)
333- Folder placement:
334 - Move items between workspace subfolders: [folders.md](./references/folders.md)
335- Access control and sensitivity labels:
336 - Grant / revoke: `fab acl set`, `fab acl rm`
337 - Set sensitivity label: `fab label set`
338 - Verify the principal first: `az ad user show`
339 - Never change permissions or labels without explicit user confirmation
340- Bindings:
341 - Rebind a thin `.Report` to a different `.SemanticModel`: [reports.md](./references/reports.md)
342 - Semantic model source rebinds (e.g. swap a lakehouse): [semantic-models.md](./references/semantic-models.md)
343
344Check references before changing metadata:
345
346- [reference.md](./references/reference.md)
347- [tags.md](./references/tags.md)
348- [folders.md](./references/folders.md)
349- [reports.md](./references/reports.md)
350- [semantic-models.md](./references/semantic-models.md)
351
352### Working with workspaces
353
354| Command | Purpose | Example |
355|---|---|---|
356| `fab mkdir` | Create workspace / item | `fab mkdir "New.Workspace" -P capacityname=MyCapacity` |
357| `fab assign` | Attach capacity / domain | `fab assign .capacities/cap.Capacity -W ws.Workspace -f` |
358| `fab unassign` | Detach capacity / domain | `fab unassign .capacities/cap.Capacity -W ws.Workspace` |
359| `fab start` / `fab stop` | Resume / pause capacity | `fab start .capacities/cap.Capacity` |
360| `fab cp -r` | Fork workspace | `fab cp "dev.Workspace" "prod.Workspace" -r -f` |
361| `fab rm` | Soft-delete (see [recovery](./references/reference.md#recovering-deleted-items)) | `fab rm "ws/Item.Type" -f` |
362
363Flags:
364- `-P key=value` (creation params for `fab mkdir`)
365- `-W` (target workspace for `fab assign` / `fab unassign`)
366- `-r` (recursive copy/move)
367- `-bpc` (block on path collision for `fab cp`)
368- `-f` (skip confirmation)
369
370Workspace-scope operations fall into a few groups:
371
372- Create and provision:
373 - Create workspace: `fab mkdir "<Name>.Workspace" -P capacityname=<cap>`
374 - Attach capacity or domain: `fab assign .capacities/<cap>.Capacity -W <ws>.Workspace`
375 - Planning context, create/get/set surface, large storage format, Spark pools, OneLake defaults, Git: [workspaces.md](./references/workspaces.md)
376- Copy, fork, download:
377 - Duplicate a workspace in-tenant: `fab cp -r "dev.Workspace" "prod.Workspace"`
378 - Dry-run the source tree first: `fab ls "dev.Workspace"`
379 - Full local snapshot (items + lakehouse files): [`scripts/download_workspace.py`](./scripts/download_workspace.py)
380- Permissions:
381 - Inspect / grant / revoke: `fab acl ls | set | rm`
382 - Tenant-wide governance audit: use the `audit-tenant-settings` skill from the `fabric-admin` plugin
383- Connections and gateways (bound to, but outside, the workspace):
384 - Credential types (WorkspaceIdentity, SPN, Basic), OAuth2 limits: [connections.md](./references/connections.md)
385 - Datasource binding, credential rotation: [gateways.md](./references/gateways.md)
386- Folders inside a workspace:
387 - Layout, nesting, conventions: [folders.md](./references/folders.md)
388
389Check references before modifying workspaces:
390
391- [workspaces.md](./references/workspaces.md)
392- [folders.md](./references/folders.md)
393- [connections.md](./references/connections.md)
394- [gateways.md](./references/gateways.md)
395
396
397### Executing or scheduling jobs (notebooks, notebook cells, pipelines, semantic model refresh)
398
399| Command | Purpose | Example |
400|---|---|---|
401| `fab job run` | Run synchronously | `fab job run "ws/ETL.Notebook" -P date:string=2025-01-01` |
402| `fab job start` | Run asynchronously | `fab job start "ws/ETL.Notebook"` |
403| `fab job run-list` | List executions | `fab job run-list "ws/Nb.Notebook"` |
404| `fab job run-status` | Check status | `fab job run-status "ws/Nb.Notebook" --id <job-id>` |
405| `fab job run-cancel` | Cancel a job | `fab job run-cancel "ws/Nb.Notebook" --id <job-id> -w` |
406| `scripts/run_notebook_checked.py` | Run a notebook + verify its exit value (status `Completed` ≠ ETL succeeded) | `python3 scripts/run_notebook_checked.py "ws/ETL.Notebook"` |
407| `fab api -A powerbi .../refreshes` | Trigger semantic model refresh | `fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes" -X post -i '{"type":"Full"}'` |
408
409Flags:
410- `-P key:type=value` (parameters, type is `string|int|bool`)
411- `--id` (job run ID)
412- `-w` (wait on cancel)
413- `--timeout` (overall timeout for synchronous runs)
414- `--polling_interval` (status poll cadence)
415
416Jobs map to different endpoints depending on item type:
417
418- Notebooks and pipelines:
419 - Run synchronously: `fab job run "ws/ETL.Notebook" -P date:string=2025-01-01`
420 - Run asynchronously: `fab job start "ws/ETL.Notebook"`
421 - Check status: `fab job run-status "ws/Nb.Notebook" --id <job-id>`
422 - List history: `fab job run-list "ws/Nb.Notebook"`
423 - Verify the REAL outcome: a job `Completed` only means the process finished -- a notebook can catch its own exception and exit a failure payload while still showing `Completed`. Read its exit value, or use [`scripts/run_notebook_checked.py`](./scripts/run_notebook_checked.py); details in [notebooks.md](./references/notebooks.md#the-notebooks-exit-value-the-only-reliable-success-signal)
424 - Python / PySpark kernels, Livy sessions, cell-level CRUD: [notebooks.md](./references/notebooks.md)
425- Semantic model refresh (not exposed as `fab job`):
426 - Trigger: `fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes" -X post -i '{"type":"Full"}'`
427 - Check current run before starting a new one (409 if already running): `fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes?\$top=1"`
428 - Enhanced refresh, incremental policies, partition targeting: [semantic-models.md](./references/semantic-models.md)
429- Dataflow refresh:
430 - Gen1 and Gen2 have different endpoints: [dataflows.md](./references/dataflows.md)
431- Scheduling:
432 - Per-item schedules via the scheduler API: [notebooks.md](./references/notebooks.md), [reference.md](./references/reference.md)
433
434Check references before running jobs:
435
436- [notebooks.md](./references/notebooks.md)
437- [semantic-models.md](./references/semantic-models.md)
438- [dataflows.md](./references/dataflows.md)
439- [reference.md](./references/reference.md)
440
441
442### Fabric admin operations (auditing, management)
443
444| Command | Purpose | Example |
445|---|---|---|
446| `fab api "admin/items"` | Cross-workspace item search | `fab api "admin/items" -P "type=SemanticModel" -q "itemEntities[?contains(name,'Sales')]"` |
447| `fab api "admin/workspaces"` | Workspace inventory | `fab api "admin/workspaces"` |
448| `fab api "admin/tenantsettings"` | Tenant settings | `fab api "admin/tenantsettings"` |
449| `fab api "admin/capacities"` | Capacity inventory | `fab api "admin/capacities"` |
450| `fab api -X post .../update` | Update tenant setting | `fab api -X post "admin/tenantsettings/<name>/update" -i body.json` |
451
452Flags:
453- `-P key=value` (query params, e.g. `type=SemanticModel`)
454- `-q` (JMESPath filter)
455- `-X post` + `-i` (write ops)
456- `--show_headers` (inspect `Retry-After` on 429)
457
458Admin-scope work is gated behind the Fabric / Power BI admin role. Confirm access first with `fab api "admin/capacities" 2>&1 | head -5`; if it errors, stop rather than retry.
459
460Two entry points cover most admin tasks:
461
462- Governance audits (tenant settings, delegated overrides, Entra SG scoping):
463 - Use the `audit-tenant-settings` skill from the `fabric-admin` plugin. It owns the curated metadata baseline, the audit + change-detection script, delegated-override enumeration, and the Entra SG investigation workflow.
464 - Invoke it whenever the question combines tenant posture with group membership, override scope, or drift against the baseline.
465- Raw admin APIs (cross-workspace search, activity events, artifact access, item search):
466 - Patterns in [admin.md](./references/admin.md)
467 - Rate limit: 25 write requests / minute; honor `Retry-After` on 429
468 - Print the exact command and wait for user confirmation before any destructive admin operation
469
470Check references before admin work:
471
472- [admin.md](./references/admin.md)
473- [permissions.md](./references/permissions.md) for workspace / item ACL exposure audits
474
475
476### Definitions and deployment (item definitions, deployment pipelines, git integration, cicd)
477
478| Command | Purpose | Example |
479|---|---|---|
480| `fab get -q "definition"` | Read raw definition | `fab get "ws/Model.SemanticModel" -q "definition" -f` |
481| `fab export` | Export item to local | `fab export "ws/Nb.Notebook" -o ./backup -f` |
482| `fab import` | Import item from local | `fab import "ws/Nb.Notebook" -i ./backup/Nb.Notebook -f` |
483| `fab cp` | Copy between workspaces | `fab cp "dev/Item" "prod.Workspace" -f` |
484| `fab api "deploymentPipelines"` | Deployment pipelines API | `fab api "deploymentPipelines" -q "value[]"` |
485
486Flags:
487- `-o` (output path for `fab export`)
488- `-i` (input path or JSON body for `fab import`)
489- `--format` (definition format for export / import)
490- `-f` (skip overwrite and sensitivity prompts)
491
492> [!IMPORTANT]
493> **The poll interval is by far the biggest performance lever for any definition change.**
494> Creating or updating an item definition is a long-running operation (LRO): the API returns
495> `202 Accepted` with a `Retry-After: 20` header. `fab import`, `nb create`, and `nb cell edit`
496> wait roughly that long between status polls, so a notebook that the server finishes in ~1s
497> takes them 25-60s. Neither `fab` nor `nb` exposes a knob to change that interval.
498> For notebook definition changes, strongly prefer [`scripts/deploy_notebook.py`](./scripts/deploy_notebook.py),
499> which polls the LRO every ~0.3s (tunable via `--poll-interval`) and creates in ~1-2s or updates
500> in place in ~1s. Auto-detects create vs update. When you must roll your own for another item
501> type, the rule is the same: poll `updateDefinition` / create at ~0.3s, not the advertised 20s.
502> ```bash
503> python3 scripts/deploy_notebook.py "ws.Workspace/ETL.Notebook" -i ./ETL.Notebook # create or update in place
504> ```
505
506Every Fabric item has a serializable definition. Move definitions between environments depending on scope:
507
508- Single item:
509 - Round-trip locally: `fab export` then `fab import` (always `mkdir -p` the output directory first; `fab export` does not create intermediate directories and fails with `[InvalidPath]`)
510 - Same-tenant shortcut, no local hop: `fab cp "dev/Item" "prod.Workspace"`
511- Semantic model as PBIP (TMDL + blank report):
512 - Export the model with `fab export`, create the report with `pbir new report`, then combine
513 them with `pbir report merge-to-thick`; see [import-download-deploy.md](./references/import-download-deploy.md)
514- Full workspace snapshot (items + lakehouse files):
515 - Backups, offline analysis, cross-tenant forks: [`scripts/download_workspace.py`](./scripts/download_workspace.py)
516- Promotion between Dev, Test, Prod:
517 - Fabric deployment pipelines API (covers all item types)
518 - Power BI pipelines API (Power BI items only, but finer-grained deploy flags like `allowPurgeData`, `allowTakeOver`)
519 - When to use each, selective deploy, LRO polling: [deployment-pipelines.md](./references/deployment-pipelines.md)
520- Git integration (connect workspace to repo, branch, commit, update from git):
521 - Workspace git section in [workspaces.md](./references/workspaces.md)
522
523Check references before deploying:
524
525- [import-download-deploy.md](./references/import-download-deploy.md) ; export / import / copy / move, PBIP round-trips, migration patterns, rebinding gotchas
526- [deployment-pipelines.md](./references/deployment-pipelines.md)
527- [semantic-models.md](./references/semantic-models.md)
528- [reports.md](./references/reports.md)
529- [paginated-reports.md](./references/paginated-reports.md)
530- [notebooks.md](./references/notebooks.md)
531- [workspaces.md](./references/workspaces.md)
532
533
534## Related skills
535
536- `audit-tenant-settings` (in the `fabric-admin` plugin) ; Fabric governance workflow covering tenant settings, delegated overrides (capacity / domain / workspace), and the Entra security groups those settings reference. Read-only; holds the curated metadata baseline and the audit + change-detection script.
537
538## Gotchas
539
540- **IMPORTANT:** DON'T try to use `fab ls` on items that aren't data items (.Lakehouse, .Warehouse, etc); use `fab ls` to find workspaces and items, and use `fab get` to look at definitions
541- ALWAYS Use the `-f` flag when using `fab get`, `fab import`, `fab export`, etc. as described above
542- ONLY fallback to `fab api` when a command doesn't exist
543- **Definition changes feel slow but aren't:** `fab import` / `nb create` / `nb cell edit` take 25-60s to push a notebook definition only because they poll the LRO at the server's `Retry-After: 20`. The work is ~1s. Use [`scripts/deploy_notebook.py`](./scripts/deploy_notebook.py) (tight-polls at ~0.3s) for definition changes; the poll interval is the single biggest lever
544
545## References
546
547**Reference map** (which references cluster together; follow the links between them, not just this list):
548
549```
550etl / notebooks
551 notebooks.md ── run jobs, exit value, scheduling
552 ├─ querying-data.md ── nb exec / Livy, DuckDB/sqlcmd, SQL-endpoint sync
553 └─ lakehouses.md ── attach, table ops, OneLake shortcuts, SQL-endpoint id
554 (cross-plugin) executing-spark, using-duckdb ── etl plugin: ephemeral Spark, local Delta
555
556data items
557 lakehouses.md · warehouses.md · sql-databases.md · semantic-models.md
558 └─ all feed querying-data.md (route priority) and notebooks.md (load then read)
559
560governance / deploy
561 admin.md · permissions.md · tags.md · folders.md
562 import-download-deploy.md ─ deployment-pipelines.md ─ workspaces.md (git status)
563 (cross-plugin) audit-tenant-settings ── fabric-admin plugin
564```
565
566**Skill references:**
567
568- [Import, Download, and Deploy](./references/import-download-deploy.md) - Export / import / copy / move items, PBIP round-trips, dev-to-prod migration patterns
569- [Querying Data](./references/querying-data.md) - Query semantic models in DAX and lakehouses or warehouses in SQL with DuckDB
570- [Lakehouses](./references/lakehouses.md) - Endpoints, file/table operations, OneLake paths
571- [Warehouses](./references/warehouses.md) - Create, browse, query via DuckDB, load data
572- [SQL Databases](./references/sql-databases.md) - Create, browse, query via DuckDB, auto-mirroring
573- [Semantic Models](./references/semantic-models.md) - TMDL, DAX, refresh, storage mode
574- [Reports](./references/reports.md) - Export, import, visuals, fields
575- [Paginated Reports](./references/paginated-reports.md) - RDL upload, export-to-file, datasources, parameters
576- [Notebooks](./references/notebooks.md) - Python/PySpark kernels, metadata, cell CRUD, Livy execution, scheduling
577- [Workspaces](./references/workspaces.md) - Create, manage, permissions
578- [Permissions](./references/permissions.md) - Sharing and distribution, workspace roles, item permissions, apps, embed, B2B, deployment pipeline permissions, licensing and capacity SKUs
579- [Deployment Pipelines](./references/deployment-pipelines.md) - CI/CD, deploy stages, selective deploy, LRO polling
580- [Dataflows](./references/dataflows.md) - Gen1 and Gen2, refresh, publish, admin
581- [Dashboards](./references/dashboards.md) - Tiles, clone (dashboards are not reports)
582- [Org Apps](./references/org-apps.md) - Read-only API for distributed content packages
583- [Scorecards](./references/scorecards.md) - Goals, check-ins, status rules (Preview API)
584- [Gateways](./references/gateways.md) - Datasources, credentials, dataset binding
585- [Folders](./references/folders.md) - Organize items into folders via API; includes best practices for structuring workspaces
586- [Tags](./references/tags.md) - Create, apply, and audit tenant/domain tags on items and workspaces via `fab api` (no native `fab tag` command)
587- [fab vs az CLI](./references/fab-vs-az-cli.md) - When to use which; capacity, networking, Key Vault, monitoring, CMK, CI/CD
588- [Admin APIs](./references/admin.md) - Cross-workspace search, tenant operations, governance
589- [API Reference](./references/fab-api.md) - Capacities, domains, misc API patterns
590- [Connections](./references/connections.md) - Create, update, list connections programmatically; credential types (WorkspaceIdentity, SPN, Basic); OAuth2 limitations
591- [Service Principals](./references/service-principals.md) - Create an SP with az CLI, grant it workspace access, clear the tenant-setting gate, authenticate `fab` as it (real login vs env-token testing), rotation and teardown
592- [Full Command Reference](./references/reference.md) - All commands detailed
593
594**Scripts** (scripts that you can execute):
595
596- [search_across_workspaces.py](./scripts/search_across_workspaces.py) ; cross-workspace governance complement to `fab find` (last visit, last refresh, owner, storage mode, capacity SKU, Copilot readiness); see [workspaces.md](./references/workspaces.md#cross-workspace-search) for when to choose which
597- [get-downstream-reports.py](./scripts/get-downstream-reports.py) ; find all reports connected to a given semantic model across accessible workspaces (no admin required)
598- [execute_dax.py](./scripts/execute_dax.py) ; execute DAX queries against semantic models; output as table, csv, or json
599- [query_lakehouse_duckdb.py](./scripts/query_lakehouse_duckdb.py) ; query lakehouse or warehouse Delta tables via DuckDB against OneLake (reuses `az login`); output as table, csv, or json
600- [query_sql_endpoint.py](./scripts/query_sql_endpoint.py) ; query lakehouse SQL endpoint, warehouse, or SQL database via `sqlcmd` (reuses `az login` through `ActiveDirectoryAzCli`); output as table, csv, or json
601- [create_direct_lake_model.py](./scripts/create_direct_lake_model.py) ; create a Direct Lake semantic model from lakehouse tables
602- [download_workspace.py](./scripts/download_workspace.py) ; download a full workspace with all item definitions and lakehouse files
603- [run_notebook_checked.py](./scripts/run_notebook_checked.py) ; run a notebook and check its exit value, exiting non-zero when the notebook's own `{ok:false}` verdict fails despite a `Completed` job status (reads the exit value via the notebook job-instance beta endpoint)
604- [deploy_notebook.py](./scripts/deploy_notebook.py) ; create or update a notebook definition fast (~1-2s) by tight-polling the LRO instead of the CLI's ~20s `Retry-After` cadence; auto-detects create vs update, `--poll-interval` is the performance lever. Strongly prefer this over `fab import` / `nb` for any notebook definition change
605
606See [scripts/README.md](./scripts/README.md) for detailed usage, arguments, and examples. Always search the `scripts/` folder before writing a new helper; a script may already exist for the task.
607
608**External references** (request markdown when possible):
609
610- fab CLI: [GitHub Source](https://github.com/microsoft/fabric-cli) | [Docs](https://microsoft.github.io/fabric-cli/)
611- Microsoft: [Fabric CLI Learn](https://learn.microsoft.com/en-us/rest/api/fabric/articles/fabric-command-line-interface)
612- APIs: [Fabric API](https://learn.microsoft.com/en-us/rest/api/fabric/articles/) | [Power BI API](https://learn.microsoft.com/en-us/rest/api/power-bi/)
613- DAX: [dax.guide](https://dax.guide/) - use `dax.guide/<function>/` e.g. `dax.guide/addcolumns/`
614- Power Query: [powerquery.guide](https://powerquery.guide/) - use `powerquery.guide/function/<function>`
615- [Power Query Best Practices](https://learn.microsoft.com/en-us/power-query/best-practices)
616
617---
618
619**Source:** [`data-goblin/power-bi-agentic-development`](https://github.com/data-goblin/power-bi-agentic-development) → `plugins/fabric-cli/skills/fabric-cli/SKILL.md`