| name | fabric-cli |
| description | Use Microsoft Fabric CLI (fab) to manage workspaces, semantic models, reports, notebooks, lakehouses, and other Fabric resources via file-system metaphor and commands. Use when deploying Fabric items, running jobs, querying data, managing OneLake files, or automating Fabric operations. Invoke this skill automatically whenever a user mentions the Fabric CLI, fab, or Fabric. |
Microsoft Fabric CLI Operations
Note: If you have access to a Bash tool (e.g., Claude Code), execute fab commands directly via Bash rather than using an MCP server.
Expert guidance for using the fab CLI to programmatically manage Fabric
When to Use This Skill
Activate automatically when tasks involve:
- Mention of the Fabric CLI, Fabric items, Power BI,
fab, or fab commands
- Managing workspaces, items, or resources
- Deploying or migrating semantic models, reports, notebooks, pipelines
- Running or scheduling jobs (notebooks, pipelines, Spark)
- Working with lakehouse/warehouse tables and data
- Using the Fabric, Power BI, or OneLake APIs
- Automating Fabric operations in scripts
Critical
- Before first use, ask the user if they have Fabric admin access, any API restrictions, or preferences for Fabric/Power BI API usage
- Remind the user to add their Fabric access level and preferences to their agent memory files (e.g., CLAUDE.md) for future sessions
- If workspace or item name is unclear, ask the user first, then verify with
fab ls or fab exists before proceeding
- The first time you use
fab run fab auth status to make sure the user is authenticated. If not, ask the user to run fab auth login to login
- Always use
fab --help and fab <command> --help the first time you use a command to understand its syntax, first
- Always try the simple
fab command alone, first before piping it
- Always use
-f when executing command if the flag is available to do so non-interactively
- 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
- Use
fab in non-interactive mode. Interactive mode doesn't work with coding agents
First Run
fab auth login
fab auth status
fab ls
fab ls "Name.Workspace"
Variable Extraction Pattern
Most workflows need 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 '"')
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes" -X post -i '{"type":"Full"}'
Quick Start
New to Fabric CLI? Here are some references you can read:
Command Reference
| Command | Purpose | Example |
|---|
| Finding Items | | |
fab ls | List items | fab ls "Sales.Workspace" |
fab ls -l | List with details | fab ls "Sales.Workspace" -l |
fab exists | Check if exists | fab exists "Sales.Workspace/Model.SemanticModel" |
fab get | Get item details | fab get "Sales.Workspace/Model.SemanticModel" |
fab get -q | Query specific field | fab get "Sales.Workspace" -q "id" |
| Definitions | | |
fab get -q "definition" | Get full definition | fab get "ws.Workspace/Model.SemanticModel" -q "definition" |
fab export | Export to local | fab export "ws.Workspace/Nb.Notebook" -o ./backup |
fab import | Import from local | fab import "ws.Workspace/Nb.Notebook" -i ./backup/Nb.Notebook |
| Running Jobs | | |
fab job run | Run synchronously | fab job run "ws.Workspace/ETL.Notebook" |
fab job start | Run asynchronously | fab job start "ws.Workspace/ETL.Notebook" |
fab job run -P | Run with params | fab job run "ws.Workspace/Nb.Notebook" -P date:string=2025-01-01 |
fab job run-list | List executions | fab job run-list "ws.Workspace/Nb.Notebook" |
fab job run-status | Check status | fab job run-status "ws.Workspace/Nb.Notebook" --id <job-id> |
| Refreshing Models | | |
fab api -A powerbi | Trigger refresh | fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes" -X post -i '{"type":"Full"}' |
fab api -A powerbi | Check refresh status | fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/refreshes?\$top=1" |
| DAX Queries | | |
fab get -q "definition" | Get model schema first | fab get "ws.Workspace/Model.SemanticModel" -q "definition" |
fab api -A powerbi | Execute DAX | fab api -A powerbi "groups/<ws-id>/datasets/<model-id>/executeQueries" -X post -i '{"queries":[{"query":"EVALUATE..."}]}' |
| Lakehouse | | |
fab ls | Browse files/tables | fab ls "ws.Workspace/LH.Lakehouse/Files" |
fab table schema | Get table schema | fab table schema "ws.Workspace/LH.Lakehouse/Tables/sales" |
fab cp | Upload/download | fab cp ./local.csv "ws.Workspace/LH.Lakehouse/Files/" |
| Management | | |
fab cp | Copy items | fab cp "dev.Workspace/Item.Type" "prod.Workspace" -f |
fab set | Update properties | fab set "ws.Workspace/Item.Type" -q displayName -i "New Name" |
fab rm | Delete item | fab rm "ws.Workspace/Item.Type" -f |
Core Concepts
Path Format
Fabric uses filesystem-like paths with type extensions:
/WorkspaceName.Workspace/ItemName.ItemType
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/Sales Model.SemanticModel"
/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 - Data stores
.SparkJobDefinition - Spark jobs
Full list: 35+ types. Use fab desc .<ItemType> to explore.
Essential Commands
Navigation & Discovery
fab ls
fab ls "Production.Workspace"
fab ls "Production.Workspace" -l
fab ls "Data.Workspace/LH.Lakehouse"
fab exists "Production.Workspace/Sales.SemanticModel"
fab get "Production.Workspace/Sales.Report"
fab get "Production.Workspace" -q "id"
Creating & Managing Resources
fab mkdir "NewWorkspace.Workspace" -P capacityname=MyCapacity
fab mkdir "Production.Workspace/NewLakehouse.Lakehouse"
fab mkdir "Production.Workspace/Pipeline.DataPipeline"
fab set "Production.Workspace/Item.Notebook" -q displayName -i "New Name"
fab set "Production.Workspace" -q description -i "Production environment"
Copy, Move, Export, Import
fab cp "Dev.Workspace/Pipeline.DataPipeline" "Production.Workspace"
fab cp "Dev.Workspace/Report.Report" "Production.Workspace/ProdReport.Report"
fab export "Production.Workspace/Model.SemanticModel" -o /tmp/exports
fab export "Production.Workspace" -o /tmp/backup -a
fab import "Production.Workspace/Pipeline.DataPipeline" -i /tmp/exports/Pipeline.DataPipeline -f
fab import "ws.Workspace/Item.Type" -i ./Item.Type -f
API Operations
Direct REST API access with automatic authentication.
Audiences:
fabric (default) - Fabric REST API
powerbi - Power BI REST API
storage - OneLake Storage API
azure - Azure Resource Manager
fab api workspaces
fab api workspaces -q "value[?type=='Workspace']"
fab api "workspaces/<workspace-id>/items"
fab api -A powerbi groups
fab api -A powerbi "datasets/<model-id>/executeQueries" -X post -i '{"queries": [{"query": "EVALUATE VALUES(Date[Year])"}]}'
fab api -X post "workspaces/<ws-id>/items" -i '{"displayName": "New Item", "type": "Lakehouse"}'
fab api -X put "workspaces/<ws-id>/items/<item-id>" -i /tmp/config.json
fab api -X delete "workspaces/<ws-id>/items/<item-id>"
fab api -A storage "WorkspaceName.Workspace/LH.Lakehouse/Files" -P resource=filesystem,recursive=false
Job Management
fab job run "Production.Workspace/ETL.Notebook"
fab job run "Production.Workspace/Pipeline.DataPipeline" --timeout 300
fab job run "Production.Workspace/ETL.Notebook" -P date:string=2024-01-01,batch:int=1000,debug:bool=false
fab job start "Production.Workspace/LongProcess.Notebook"
fab job run-list "Production.Workspace/ETL.Notebook"
fab job run-status "Production.Workspace/ETL.Notebook" --id <job-id>
fab job run-sch "Production.Workspace/Pipeline.DataPipeline" --type daily --interval 10:00,16:00 --start 2024-11-15T09:00:00 --enable
fab job run-sch "Production.Workspace/Pipeline.DataPipeline" --type weekly --interval 10:00 --days Monday,Friday --enable
fab job run-cancel "Production.Workspace/ETL.Notebook" --id <job-id>
Table Operations
fab table schema "Data.Workspace/LH.Lakehouse/Tables/dbo/customers"
fab table load "Data.Workspace/LH.Lakehouse/Tables/sales" --file "Data.Workspace/LH.Lakehouse/Files/daily_sales.csv" --mode append
fab table optimize "Data.Workspace/LH.Lakehouse/Tables/transactions" --vorder --zorder customer_id,region
fab table vacuum "Data.Workspace/LH.Lakehouse/Tables/temp_data" --retain_n_hours 48
Common Workflows
Semantic Model Management
fab ls "ws.Workspace" | grep ".SemanticModel"
fab get "ws.Workspace/Model.SemanticModel" -q definition
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes" -X post -i '{"type":"Full"}'
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes?\$top=1"
Execute DAX:
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/executeQueries" -X post \
-i '{"queries":[{"query":"EVALUATE TOPN(5, '\''TableName'\'')"}]}'
DAX rules: EVALUATE required, single quotes around tables ('Sales'), qualify columns ('Sales'[Amount]).
For full details: semantic-models.md | querying-data.md
Report Operations
fab get "ws.Workspace/Report.Report" -q definition
fab export "ws.Workspace/Report.Report" -o /tmp/exports -f
fab import "ws.Workspace/Report.Report" -i /tmp/exports/Report.Report -f
fab set "ws.Workspace/Report.Report" -q semanticModelId -i "<new-model-id>"
For full details: reports.md
Lakehouse/Warehouse Operations
fab ls "Data.Workspace/LH.Lakehouse/Files"
fab ls "Data.Workspace/LH.Lakehouse/Tables/dbo"
fab cp ./local-data.csv "Data.Workspace/LH.Lakehouse/Files/data.csv"
fab cp "Data.Workspace/LH.Lakehouse/Files/data.csv" ~/Downloads/
fab table load "Data.Workspace/LH.Lakehouse/Tables/sales" --file "Data.Workspace/LH.Lakehouse/Files/sales.csv"
fab table optimize "Data.Workspace/LH.Lakehouse/Tables/sales" --vorder --zorder customer_id
Environment Migration
fab export "Dev.Workspace" -o /tmp/migration -a
fab import "Production.Workspace/Pipeline.DataPipeline" -i /tmp/migration/Pipeline.DataPipeline
fab import "Production.Workspace/Report.Report" -i /tmp/migration/Report.Report
Cross-Workspace Search
DataHub V2 API (Recommended)
Use scripts/search_across_workspaces.py for cross-workspace search with rich metadata not available elsewhere:
python3 scripts/search_across_workspaces.py --type Model
python3 scripts/search_across_workspaces.py --type Model --filter "Sales"
python3 scripts/search_across_workspaces.py --type Model --not-visited-since 2024-06-01
python3 scripts/search_across_workspaces.py --type PowerBIReport --owner "kurt"
python3 scripts/search_across_workspaces.py --type Model --storage-mode directlake
python3 scripts/search_across_workspaces.py --type Lakehouse --workspace "fit-data"
python3 scripts/search_across_workspaces.py --type Model --output json
python3 scripts/search_across_workspaces.py --type Model --sort last-visited --sort-order asc
python3 scripts/search_across_workspaces.py --list-types
Unique DataHub fields (not available via fab api or admin APIs):
lastVisitedTimeUTC - When item was last opened/used
storageMode - Import, DirectQuery, or DirectLake
ownerUser - Full owner details (name, email)
capacitySku - F2, F64, PP, etc.
isDiscoverable - Whether item appears in search
Important type mappings:
- Semantic models: use
--type Model (not SemanticModel)
- Dataflows: use
--type DataFlow (capital F)
- Notebooks: use
--type SynapseNotebook
Admin APIs (Requires Admin Role)
If you have Fabric/Power BI admin access:
fab api "admin/items" -P "type=SemanticModel" -q "itemEntities[?contains(name, 'Sales')]"
fab api "admin/items" -P "type=Notebook" -q "itemEntities[].{name:name,workspace:workspaceId}"
fab api "admin/items" -P "type=Lakehouse"
For full admin API reference: admin.md
Key Patterns
JMESPath Queries
Filter and transform JSON responses with -q:
-q "id"
-q "displayName"
-q "properties.sqlEndpointProperties"
-q "definition.parts[0]"
-q "value[?type=='Lakehouse']"
-q "value[?contains(name, 'prod')]"
-q "value[0]"
-q "definition.parts[?path=='model.tmdl'] | [0]"
Error Handling & Debugging
fab api workspaces --show_headers
fab get "Production.Workspace/Item" -v
fab api workspaces -o /tmp/workspaces.json
Performance Optimization
- Use
ls for fast listing - Much faster than get
- Use
exists before operations - Check before get/modify
- Filter with
-q - Get only what you need
- Use GUIDs in automation - More stable than names
Common Flags
-f, --force - Skip confirmation prompts
-v, --verbose - Verbose output
-l - Long format listing
-a - Show hidden items
-o, --output - Output file path
-i, --input - Input file or JSON string
-q, --query - JMESPath query
-P, --params - Parameters (key=value)
-X, --method - HTTP method (get/post/put/delete/patch)
-A, --audience - API audience (fabric/powerbi/storage/azure)
--show_headers - Show response headers
--timeout - Timeout in seconds
Important Notes
- All examples assume
fab is installed and authenticated
- Paths require proper extensions (
.Workspace, .SemanticModel, etc.)
- Quote paths with spaces:
"My Workspace.Workspace"
- Use
-f for non-interactive scripts (skips prompts)
- Semantic model updates: Use Power BI API (
-A powerbi) for DAX queries and dataset operations
Need More Details?
For specific item type help:
fab desc .<ItemType>
For command help:
fab --help
fab <command> --help
References
Skill references:
- Querying Data - Query semantic models and lakehouse tables
- Semantic Models - TMDL, DAX, refresh, storage mode
- Reports - Export, import, visuals, fields
- Notebooks - Job execution, parameters
- Workspaces - Create, manage, permissions
- Admin APIs - Cross-workspace search, tenant operations, governance
- API Reference - Capacities, gateways, pipelines, domains, dataflows, apps
- Full Command Reference - All commands detailed
- Quick Start Guide - Copy-paste examples
External references (request markdown when possible):