npx skills add ...
npx skills add microsoft/fabric-apps-analytic-templates --skill fabric-cli
npx skills add microsoft/fabric-apps-analytic-templates --skill fabric-cli
How to use fabric-app-data CLI to manage Fabric data source connections. Maintain workspace/item IDs in a fabric.yaml file with profiles, add connections by ID or Fabric portal URL, and generate TypeScript config for use with @microsoft/fabric-app-data.
The fabric-app-data CLI manages Fabric data source connections in a
fabric.yaml file. It supports multiple profiles (dev, staging,
production) and generates TypeScript config that the @microsoft/fabric-app-data
consumes at runtime.
Then in your app:
All commands except init walk up the directory tree from the
current working directory until they find a fabric.yaml. This means
you can run the CLI from any subdirectory of your project (e.g. from
src/queries/ or a nested package) and it will pick up the project's
root fabric.yaml automatically.
init is the exception — it always writes fabric.yaml to the
current working directory, so run it from the project root.
npx fabric-app-data initCreate a new fabric.yaml in the current directory.
npx fabric-app-data addAdd a connection to a profile. Two modes:
From Fabric portal URL (preferred):
Explicit IDs:
Important: Use exactly these flag names. The short flags are -w and -i. The long flags are --workspace and --item. Do NOT use --workspace-id or --item-id — those do not exist.
The URL parser extracts workspace ID, item ID, and type automatically.
Supported URL segments: semanticmodels, modeling, lakehouses,
warehouses. "me" is accepted as workspace ID for My Workspace items.
Options:
-p, --profile <name> — target profile (defaults to active)npx fabric-app-data remove <alias>Remove a connection by alias.
npx fabric-app-data listList all connections in a profile.
npx fabric-app-data use <profile>Switch the active profile and auto-regenerate the config file.
npx fabric-app-data generateGenerate fabric.generated.ts from the active profile.
npx fabric-app-data queryExecute a DAX query against a semantic model using the same SDK pipeline as the running app. Aliases: execute, exec.
Options:
-q, --query <query> — inline DAX query text-f, --file <path> — path to a .dax file (alternative to --query)-l, --limit <rows> — maximum rows to return (default: 1000, max: 1000)-p, --profile <name> — profile name (defaults to activeProfile)Result trimming: By default, results are capped at 1000 rows to keep output manageable. When the result is trimmed, the JSON output includes a _cliWarning field indicating how many rows were returned out of the total. This is a CLI-only limitation — the full dataset is available in the running app. If more rows are needed, refine the DAX query with filters or aggregations instead.
fabric.generated.ts exports a plain config object:
Add fabric.generated.ts to .gitignore — regenerate from fabric.yaml
as needed.
import { FabricClient } from "@microsoft/fabric-app-data";
import { fabricConfig } from "./fabric.generated.js";
const client = new FabricClient({ proxy, ...fabricConfig });npx fabric-app-data init # default "dev" profile
npx fabric-app-data init -p production # custom profile name
npx fabric-app-data init --force # overwrite existingnpx fabric-app-data add <alias> --from-url "<Fabric portal URL>"npx fabric-app-data add semanticModel <alias> -w <workspaceId> -i <itemId>npx fabric-app-data remove sales
npx fabric-app-data remove sales -p stagingnpx fabric-app-data list
npx fabric-app-data list -p productionnpx fabric-app-data use production
npx fabric-app-data use staging -o src/config/fabric.generated.tsnpx fabric-app-data generate
npx fabric-app-data generate -o src/fabric.generated.ts
npx fabric-app-data generate -p productionnpx fabric-app-data query <alias> --query '<DAX>'
npx fabric-app-data query <alias> --file src/queries/revenue.dax
npx fabric-app-data query semanticModel <alias> --query '<DAX>' # explicit source type
npx fabric-app-data query <alias> --query '<DAX>' --limit 50 # return at most 50 rows
npx fabric-app-data query <alias> --query '<DAX>' --profile stagingactiveProfile: dev
profiles:
dev:
semanticModels:
sales:
workspaceId: "00c98f7c-..."
itemId: "03f2dc11-..."
myModel:
workspaceId: "me"
itemId: "c078a68d-..."
production:
semanticModels:
sales:
workspaceId: "aabbccdd-..."
itemId: "11223344-..."// fabric.generated.ts — AUTO-GENERATED from fabric.yaml (profile: dev). Do not edit.
export const fabricConfig = {
semanticModels: {
sales: {
workspaceId: '00c98f7c-...',
itemId: '03f2dc11-...',
},
},
} as const;