> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/m/microsoft-power-bi.md).

# Microsoft Power BI

Microsoft Power BI is the analytics service of Microsoft. OctoXLabs reads the users of the workspaces that the service principal belongs to, with their workspace membership, and the Power BI capacities that the service principal can see.

## Use cases

* List Power BI users.

```
Adapters = microsoft-power-bi
```

* Find Power BI users that belong to a given workspace.

```
Adapters = microsoft-power-bi AND MembersOf ~ <workspace name>
```

## Before you begin

### Network

| Source              | Destination                                           | Port | Protocol |
| ------------------- | ----------------------------------------------------- | ---- | -------- |
| OctoXLabs connector | login.microsoftonline.com                             | 443  | HTTPS    |
| OctoXLabs connector | api.powerbi.com (or the host in the Domain parameter) | 443  | HTTPS    |

### Required permissions

| Scope or role                                                                        | Permission                     | Needed for                          |
| ------------------------------------------------------------------------------------ | ------------------------------ | ----------------------------------- |
| Member or Admin on each workspace (Workspace access)                                 | Read                           | Workspace users                     |
| Admin or Assign rights on capacities                                                 | Read                           | Capacities                          |
| Allow service principals to use Power BI APIs (Tenant settings > Developer settings) | Enabled for the security group | Service principal access to the API |

Do not add Power BI API permissions to the app registration. A service principal never uses them and they can cause errors. Power BI returns only the workspaces the service principal was added to. Other workspaces are left out without an error.

## Create credentials in Microsoft Power BI

{% stepper %}
{% step %}

### Register an app

In Microsoft Entra ID, register an app and create a client secret. Copy the secret value right away. Copy the Directory (tenant) ID and Application (client) ID from the overview page.
{% endstep %}

{% step %}

### Create a security group

Create a Microsoft Entra security group and add the service principal of the app to it.
{% endstep %}

{% step %}

### Enable service principal access

In the Power BI Admin portal, open Tenant settings > Developer settings. Enable Allow service principals to use Power BI APIs for that security group. In newer tenants the setting is named Service principals can call Fabric public APIs.
{% endstep %}

{% step %}

### Add the service principal to workspaces

In each workspace to collect, open Workspace access and add the service principal, or the security group, as Member or Admin.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter                       | Required | Type    | Default         | Description                                             |
| ------------------------------- | -------- | ------- | --------------- | ------------------------------------------------------- |
| Domain (`domain`)               | No       | String  | api.powerbi.com | Power BI REST API host.                                 |
| Tenant ID (`tenant_id`)         | Yes      | String  |                 | Directory (tenant) ID.                                  |
| Client ID (`client_id`)         | Yes      | String  |                 | Application (client) ID.                                |
| Client Secret (`client_secret`) | Yes      | String  |                 | Value of a client secret.                               |
| Page Size (`page_size`)         | No       | Integer | 100             | Workspaces and workspace users per request (minimum 1). |
| Is Secure (`is_secure`)         | No       | Boolean | True            | Use HTTPS.                                              |
| Proxy (`proxy`)                 | No       | String  |                 | Proxy as `host:port`.                                   |
| Timeout (`timeout`)             | No       | Integer | 30              | Seconds to wait for API responses.                      |

## Troubleshooting

| Error message                                                    | Cause                                                                  | Fix                                                                                       |
| ---------------------------------------------------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| The service principal is not a member of any Power BI workspace. | No workspace is visible to the service principal. Logged as a warning. | Add the service principal to the workspaces.                                              |
| Could not read the users of any of the Power BI workspaces.      | Every workspace user call failed.                                      | Check the workspace role (Member or Admin) and the tenant setting for service principals. |
| Power BI request failed with status `:`                          | A 403 other than an expired token, or the retries ran out.             | Check the tenant setting and the workspace access.                                        |

## Change history

{% hint style="info" %}
Available starting from version 6.9.1.
{% endhint %}
