/powerbi-fabric:pbi-embed <report-id> [--mode app-owns-data|user-owns-data] [--rls <role>] [--workspace <id>] [--react]from powerbi-fabric
Generates Power BI Embedded integration code — server-side embed token generation (App Owns Data with service principal or User Owns Data with delegated token) and client-side embedding using the powerbi-client JavaScript SDK. Optional React component wrapper.
Ships in powerbi-fabric. Installing the plugin adds it to Claude Code.
Generate complete Power BI Embedded integration code based on the provided report ID and options.
Parse the following from $ARGUMENTS:
report-id (required): The Power BI report GUID--mode: app-owns-data (default) or user-owns-data--rls <role>: Optional RLS role name for Row-Level Security--workspace <id>: Optional workspace (group) GUID; required for scoped embed token--react: If present, wrap the client embed in a React functional componentIf --workspace is not provided but --mode app-owns-data is used, note that the workspace ID is required for the GenerateToken API call and prompt the user to provide it.
Generate TypeScript code for server-side embed token generation using MSAL ConfidentialClientApplication.
Generate a .env file listing:
AZURE_TENANT_ID=<your-tenant-id>
AZURE_CLIENT_ID=<your-client-id>
AZURE_CLIENT_SECRET=<your-client-secret>
PBI_WORKSPACE_ID=<workspace-id-from-argument>
PBI_REPORT_ID=<report-id-from-argument>
Generate a complete TypeScript file pbi-token-service.ts:
ConfidentialClientApplication from @azure/msal-nodehttps://analysis.windows.net/powerbi/api/.defaultPOST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/reports/{reportId}/GenerateToken{ "accessLevel": "View" }--rls <role> is provided, include in request body:
{
"accessLevel": "View",
"identities": [
{
"username": "[email protected]",
"roles": ["<role>"],
"datasets": ["<datasetId>"]
}
]
}
Note: the datasetId is the dataset bound to the report -- add a comment that the caller must supply the datasetId{ embedUrl, embedToken, tokenExpiry } to the clientGenerate a pbi-embed-client.js file:
powerbi-client via CDN or npm importIEmbedConfiguration object:
const config: pbi.IEmbedConfiguration = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: embedToken,
embedUrl: embedUrl,
id: reportId,
settings: {
navContentPaneEnabled: false,
filterPaneEnabled: true
}
};
powerbi.embed(container, config)report.on('loaded', ...), report.on('error', ...)tokenExpired event handler for proactive token refresh:
report.on('tokenExpired', async () => {
const newToken = await fetchFreshEmbedToken(); // call your server endpoint
report.setAccessToken(newToken.embedToken);
});
If --react flag is provided, wrap the embed in a React functional component:
useRef for the container divuseEffect for initialization (runs once on mount with [embedUrl, embedToken] deps)PowerBIEmbedembedUrl: string, embedToken: string, reportId: stringpowerbi.reset(containerRef.current) on unmountGenerate client-side MSAL PublicClientApplication code using @azure/msal-browser:
Report.Read.AlltokenType: models.TokenType.AadRead skills/powerbi-analytics/references/pbi-rest-api.md Embedding section for GenerateToken endpoint details and request body structure.
Always include a comment block explaining the embed token lifecycle:
// Token Lifecycle:
// - Default embed token expiry: 1 hour
// - Implement the 'tokenExpired' event to refresh proactively
// - For long-lived sessions, refresh the token 5 minutes before expiry
// - Use the 'tokenExpiry' field from GenerateToken response to schedule refresh
Files this command reads when invoked
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
19 commands in this plugin
/pbi-calc-groupAuthor a calculation group (time intelligence, currency, or format switching) as TMDL, collapsing repeated measure variants into reusable calculation items./pbi-dashboard-createCreate Power BI dashboards in Fabric with deterministic setup and verification checks./pbi-dataflowScaffold a Fabric Dataflow Gen2 Power Query M definition for common source types with publishing guidancenpx claudepluginhub thelobbi/claude-m --plugin powerbi-fabricOther plugins' commands for the same job