Loading...
Loading...
Use Fabric CLI for Power BI operations — semantic models, reports, DAX queries, refresh, gateways. Activate when users work with Power BI items, need to refresh datasets, execute DAX, manage reports, or troubleshoot refresh failures.
npx skill4agent add microsoft/fabric-cli fabric-cli-powerbifabfabric-cli-corefab auth status--help| Script | Purpose | Usage |
|---|---|---|
| Trigger and monitor semantic model refresh | |
| Show refresh history and failure details | |
| Rebind report to different semantic model | |
scripts/| Entity Suffix | Type | Description |
|---|---|---|
| Semantic Model | Power BI dataset (tabular model) |
| Report | Power BI report (visualizations) |
| Dashboard | Power BI dashboard (pinned tiles) |
| Dataflow | Power Query dataflow |
| Paginated Report | RDL-based paginated report |
# Semantic model
Production.Workspace/Sales.SemanticModel
# Report connected to model
Production.Workspace/SalesReport.Report
# Dashboard
Production.Workspace/ExecutiveDash.Dashboard# Check if model exists
fab exists "ws.Workspace/Model.SemanticModel"
# Get model properties
fab get "ws.Workspace/Model.SemanticModel"
# Get model ID (needed for Power BI API calls)
fab get "ws.Workspace/Model.SemanticModel" -q "id"
# Get full definition (TMDL)
fab get "ws.Workspace/Model.SemanticModel" -q "definition"# Export to local directory (PBIP format with TMDL)
fab export "ws.Workspace/Model.SemanticModel" -o ./exports -fModel.SemanticModel/
├── .platform
├── definition.pbism
└── definition/
├── model.tmdl
├── tables/
│ ├── Sales.tmdl
│ └── Date.tmdl
└── relationships.tmdl# Import from PBIP folder
fab import "ws.Workspace/Model.SemanticModel" -i ./exports/Model.SemanticModel -f
# Copy between workspaces
fab cp "Dev.Workspace/Model.SemanticModel" "Prod.Workspace/Model.SemanticModel" -f# Get IDs
WS_ID=$(fab get "ws.Workspace" -q "id" | tr -d '"')
MODEL_ID=$(fab get "ws.Workspace/Model.SemanticModel" -q "id" | tr -d '"')
# Trigger full refresh
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes" -X post -i '{"type":"Full"}'
# Check refresh status
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes?\$top=1"# Refresh specific tables
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes" -X post -i '{
"type": "Full",
"commitMode": "transactional",
"objects": [
{"table": "Sales"},
{"table": "Inventory"}
]
}'
# Refresh with retry
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes" -X post -i '{
"type": "Full",
"retryCount": 3
}'# Get current schedule
fab api -A powerbi "datasets/$MODEL_ID/refreshSchedule"
# Set daily refresh at 6 AM UTC
fab api -A powerbi "datasets/$MODEL_ID/refreshSchedule" -X patch -i '{
"enabled": true,
"days": ["Monday","Tuesday","Wednesday","Thursday","Friday"],
"times": ["06:00"],
"localTimeZoneId": "UTC"
}'# Get refresh history
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes"
# Common failure patterns:
# - "credentials" → Update data source credentials
# - "gateway" → Check gateway status
# - "timeout" → Use enhanced refresh with smaller batches
# - "memory" → Optimize model or use incremental refreshMODEL_ID=$(fab get "ws.Workspace/Model.SemanticModel" -q "id" | tr -d '"')
# Simple query
fab api -A powerbi "datasets/$MODEL_ID/executeQueries" -X post -i '{
"queries": [{"query": "EVALUATE VALUES(Date[Year])"}]
}'
# Aggregation query
fab api -A powerbi "datasets/$MODEL_ID/executeQueries" -X post -i '{
"queries": [{
"query": "EVALUATE SUMMARIZECOLUMNS(Date[Year], \"Total\", SUM(Sales[Amount]))"
}]
}'
# TOPN query
fab api -A powerbi "datasets/$MODEL_ID/executeQueries" -X post -i '{
"queries": [{
"query": "EVALUATE TOPN(10, Product, [Total Sales], DESC)"
}]
}'
# Query with parameters
fab api -A powerbi "datasets/$MODEL_ID/executeQueries" -X post -i '{
"queries": [{
"query": "EVALUATE FILTER(Sales, Sales[Year] = @Year)",
"parameters": [{"name": "@Year", "value": "2024"}]
}]
}'# Check exists
fab exists "ws.Workspace/Report.Report"
# Get properties
fab get "ws.Workspace/Report.Report"
# Get connected model
fab get "ws.Workspace/Report.Report" -q "definition.parts[?contains(path, 'definition.pbir')].payload | [0]"# Export to PBIP format
fab export "ws.Workspace/Report.Report" -o ./exports -f# Copy within workspace
fab cp "ws.Workspace/Report.Report" "ws.Workspace/ReportCopy.Report" -f
# Copy to another workspace
fab cp "Dev.Workspace/Report.Report" "Prod.Workspace/Report.Report" -fWS_ID=$(fab get "ws.Workspace" -q "id" | tr -d '"')
REPORT_ID=$(fab get "ws.Workspace/Report.Report" -q "id" | tr -d '"')
NEW_MODEL_ID=$(fab get "ws.Workspace/NewModel.SemanticModel" -q "id" | tr -d '"')
fab api -A powerbi "groups/$WS_ID/reports/$REPORT_ID/Rebind" -X post -i "{
\"datasetId\": \"$NEW_MODEL_ID\"
}"# Export to PDF
fab api -A powerbi "groups/$WS_ID/reports/$REPORT_ID/ExportTo" -X post -i '{
"format": "PDF"
}'
# Poll for completion, then download# Tenant-level gateways (hidden entity)
fab ls .gateways
# Get gateway details
fab get ".gateways/MyGateway.Gateway"GATEWAY_ID=$(fab get ".gateways/MyGateway.Gateway" -q "id" | tr -d '"')
# List data sources on gateway
fab api -A powerbi "gateways/$GATEWAY_ID/datasources"
# Get data source status
fab api -A powerbi "gateways/$GATEWAY_ID/datasources/$DATASOURCE_ID"# Update credentials (basic auth example)
fab api -A powerbi "gateways/$GATEWAY_ID/datasources/$DATASOURCE_ID" -X patch -i '{
"credentialDetails": {
"credentialType": "Basic",
"credentials": "{\"credentialData\":[{\"name\":\"username\",\"value\":\"user\"},{\"name\":\"password\",\"value\":\"pass\"}]}",
"encryptedConnection": "Encrypted",
"encryptionAlgorithm": "None",
"privacyLevel": "Organizational"
}
}'WS_ID=$(fab get "ws.Workspace" -q "id" | tr -d '"')
MODEL_ID=$(fab get "ws.Workspace/Model.SemanticModel" -q "id" | tr -d '"')
# Take over semantic model ownership
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/Default.TakeOver" -X post#!/bin/bash
DEV_WS="Dev.Workspace"
PROD_WS="Prod.Workspace"
# 1. Export from dev
fab export "$DEV_WS/Sales.SemanticModel" -o ./deploy -f
fab export "$DEV_WS/SalesReport.Report" -o ./deploy -f
# 2. Import to prod
fab import "$PROD_WS/Sales.SemanticModel" -i ./deploy/Sales.SemanticModel -f
fab import "$PROD_WS/SalesReport.Report" -i ./deploy/SalesReport.Report -f
# 3. Trigger refresh
PROD_WS_ID=$(fab get "$PROD_WS" -q "id" | tr -d '"')
MODEL_ID=$(fab get "$PROD_WS/Sales.SemanticModel" -q "id" | tr -d '"')
fab api -A powerbi "groups/$PROD_WS_ID/datasets/$MODEL_ID/refreshes" -X post -i '{"type":"Full"}'
# 4. Verify
fab api -A powerbi "groups/$PROD_WS_ID/datasets/$MODEL_ID/refreshes?\$top=1" -q "value[0].status"# Export definition for version control
fab export "Prod.Workspace/Model.SemanticModel" -o ./backups/$(date +%Y%m%d) -f
git add ./backups/
git commit -m "Backup Model $(date +%Y-%m-%d)"# Monitor partition creation
fab api -A powerbi "groups/$WS_ID/datasets/$MODEL_ID/refreshes?\$top=5"