Fabric cli

From data-goblin/power-bi-agentic-development · View interactive version

Fabric cli is an AI agent skill from the GitHub repository data-goblin/power-bi-agentic-development. Expert guidance for the Fabric CLI (`fab`) and the Fabric and Power BI REST APIs: workspaces, items, lakehouses, notebooks, pipelines, semantic models, reports, capacities, OneLake, deployment and admin. Also estimates the capacity units (CU) an operation will consume and its impact on the capacity

How to use this skill

Skill file

Fabric CLI

Guidance for using fab to programmatically manage Fabric & Power BI service

Record generic fab learnings (errors, user preferences) in .claude/rules/fabric-cli.md so

later sessions start with them; item- or task-specific findings do not go there.

Critical general rules

Capacity cost: estimate before acting

Bursting hides cost: operations finish fast and their CUs are smoothed into the next 5 to 64 minutes (interactive) or 24 hours (background). On a small F SKU one operation can use more than a day of capacity, and the carry forward then throttles every workspace on it until idle capacity pays it back, which on an F2 can take weeks.

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:

Quickstart guide

You must read and understand the common list of operations with simple examples

  1. Check the commands, syntax, and auth status: fab --help and fab auth status
  2. Check if the item exists if the user gave the workspace and item name: fab exists "spaceparts-dev.Workspace/spaceparts-otc-full.SemanticModel"
  3. 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 CODE4; see workspaces.md for the delta.
  4. Find the workspace: fab ls
  5. Find the item: fab ls "Workspace Name.Workspace"
  6. Check the commands for that item:
  1. What's in that item; what's it for; what is it?:
  1. Get files, tables, or table schemas:
  1. Query data (always prefer the wrapper scripts over raw fab api / duckdb / sqlcmd; they resolve IDs, hosts, and auth for you):
  1. 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"
  2. Review or manage permissions:
  1. Deploy items to Fabric: fab import "ws.Workspace/New.Notebook" -i ./local-path/Nb.Notebook -f
  2. Download items from Fabric: fab export "ws.Workspace/Nb.Notebook" -o ./backup -f (always mkdir -p ./backup first)
  3. 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
  4. Open item in Fabric via browser: fab open "spaceparts-dev.SpaceParts/Amazing Report.Report"
  5. 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"
  6. Using Azure CLI (advanced) when Fabric CLI doesn't suffice:

Essential Concepts

For information about any concepts related to Power BI or Fabric you must search or fetch the Microsoft Learn documentation at https://learn.microsoft.com (or use the pbi-search CLI) and ask the user questions with the AskUserQuestion tool; NEVER guess or make assumptions.

Workspaces

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:

Common Item Types

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:

Fabric discovery follows a drill-down pattern:

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:

Fabric exposes three query paths depending on the source; always prefer the wrapper scripts -- they resolve IDs, hosts, and auth for you:

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:

Metadata and access changes fall into a few groups:

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:

Workspace-scope operations fall into a few groups:

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:

Jobs map to different endpoints depending on item type:

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:

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:

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:

[!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 CODE0,

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.

```bash

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:

them with pbir report merge-to-thick; see import-download-deploy.md

Check references before deploying:

Related skills

Gotchas

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:

Scripts (scripts that you can execute):

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):

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.