Pull Power BI metadata into Semantica using the REST API with Azure AD OAuth2 client-credentials authentication.

Installation

requests ships with Semantica as a core dependency, so this connector works as soon as the package is installed — there is no extra to install. The module is a lazy export: import semantica.ingest does not load it until you first touch PowerBIIngestor.
This connector reads metadata — workspaces, datasets, reports and dataflows. It does not execute DAX queries or export dataset rows; the Power BI REST API exposes catalog information, not table data.

Basic Usage

Use environment variables (or a .env file with python-dotenv) to keep credentials out of source code. PowerBIIngestor() with no arguments reads from POWERBI_* environment variables automatically.

Authentication

The connector uses the Azure AD OAuth2 client-credentials flow. Register an application in Azure AD, grant it access to the Power BI service, and supply its tenant, client ID and secret. Required configuration: Missing any of the first three raises ValidationError before any network call is made. Tokens are cached and refreshed automatically shortly before expiry. The client secret is never written to logs.

Scoping to One Workspace

Pass a workspace (group) ID to read a single workspace; omit it to walk every workspace the service principal can see, collecting datasets, reports and dataflows from each and tagging every record with the workspace_id it came from. That per-workspace walk is deliberate: the unscoped myorg endpoints only cover My workspace, and dataflows have no unscoped endpoint.
Select only the resources you need with include (an empty list pulls nothing):

Document Output

export_as_documents returns the standard {"id", "text", "metadata"} shape, so the output feeds directly into GraphBuilder:
Each document’s metadata carries source: "powerbi", a resource_type of workspace, dataset, report or dataflow, plus the original API fields.

Security

Every outbound HTTP call — including the token request — goes through Semantica’s shared SSRF guard, so a user-supplied endpoint cannot reach private, loopback or link-local address space. Set allow_private_ips=True only for self-hosted deployments that genuinely need it.