# Microsoft Power BI CLI

The Paradime SDK provides CLI commands to interact with Microsoft Power BI, allowing you to trigger dataset refreshes and list available datasets with real-time monitoring capabilities.

{% hint style="warning" %}
🔑 **Azure AD Application Required**

You will need an Azure AD application with Power BI API permissions to use these commands. You can create and configure them in your Azure portal. See our docs [here](/app-help/documentation/integrations/dashboards/power-bi.md).

**Configure Power BI API permissions**

Add the `Dataset.ReadWrite.All` application permission for the Power BI Service.
{% endhint %}

## Refresh Power BI Datasets

Trigger refreshes for one or more Power BI datasets with parallel execution and comprehensive status reporting.

### CLI Command

```bash
paradime run power-bi-refresh
```

#### Options

| Flag                         | Type                      | Description                                                                                                                 |
| ---------------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| `--dataset-name`             | Required, TEXT (multiple) | The name of the Power BI dataset(s) you want to refresh. Can specify multiple datasets by repeating the flag.               |
| `--client-id`                | Required, TEXT            | Your Azure AD application client ID. Can be set via `POWER_BI_CLIENT_ID` environment variable.                              |
| `--client-secret`            | Required, TEXT            | Your Azure AD application client secret. Can be set via `POWER_BI_CLIENT_SECRET` environment variable.                      |
| `--tenant-id`                | Required, TEXT            | Your Azure AD tenant ID. Can be set via `POWER_BI_TENANT_ID` environment variable.                                          |
| `--group-id`                 | Required, TEXT            | The Power BI workspace group ID. Can be set via `POWER_BI_GROUP_ID` environment variable.                                   |
| `--refresh-request-body-b64` | Optional, TEXT            | Base64 encoded JSON string for refresh parameters. Can be set via `POWER_BI_REFRESH_REQUEST_BODY_B64` environment variable. |

{% hint style="info" %}
**Recommended Setup**

For security and convenience, set your Power BI credentials as environment variables:

```bash
POWER_BI_CLIENT_ID="your_client_id"
POWER_BI_CLIENT_SECRET="your_client_secret"
POWER_BI_TENANT_ID="your_tenant_id"
POWER_BI_GROUP_ID="your_workspace_group_id"
```

{% endhint %}

## Dataset Refresh Examples

### Refresh a single dataset

```bash
# Using environment variables (recommended)
paradime run power-bi-refresh --dataset-name "Sales Dashboard"

# Or with explicit flags
paradime run power-bi-refresh \
  --client-id "your_client_id" \
  --client-secret "your_client_secret" \
  --tenant-id "your_tenant_id" \
  --group-id "your_group_id" \
  --dataset-name "Sales Dashboard"
```

### Refresh multiple datasets in parallel

```bash
# Using environment variables (recommended)
paradime run power-bi-refresh \
  --dataset-name "Sales Dashboard" \
  --dataset-name "Marketing Analytics" \
  --dataset-name "Financial Reports"

# Or with explicit flags
paradime run power-bi-refresh \
  --client-id "your_client_id" \
  --client-secret "your_client_secret" \
  --tenant-id "your_tenant_id" \
  --group-id "your_group_id" \
  --dataset-name "Sales Dashboard" \
  --dataset-name "Marketing Analytics" \
  --dataset-name "Financial Reports"
```

### Refresh with custom parameters

```bash
# Refresh with specific partition or table refresh
export POWER_BI_REFRESH_REQUEST_BODY_B64='eyJ0eXBlIjoiZnVsbCIsImNvbW1pdE1vZGUiOiJ0cmFuc2FjdGlvbmFsIiwibWF4UGFyYWxsZWxpc20iOjJ9'

paradime run power-bi-refresh \
  --dataset-name "Large Dataset" \
  --refresh-request-body-b64 "$POWER_BI_REFRESH_REQUEST_BODY_B64"
```

{% hint style="success" %}

#### Sample Output

```
Power BI refresh started in group 7a76b78b-0000-4cec-8202-648224ab54e2...
2025-09-11 13:36:50,962 - Refreshing Power BI dataset: 0dfed4be-45fjf-4e83-90d7-497dcbefdc5f
```

{% endhint %}

## List Power BI Datasets

List all available Power BI datasets in a workspace with their IDs, names, and refresh status.

### CLI Command

```bash
paradime run power-bi-list-datasets
```

#### Options

| Flag              | Type           | Description                                                                                            |
| ----------------- | -------------- | ------------------------------------------------------------------------------------------------------ |
| `--client-id`     | Required, TEXT | Your Azure AD application client ID. Can be set via `POWER_BI_CLIENT_ID` environment variable.         |
| `--client-secret` | Required, TEXT | Your Azure AD application client secret. Can be set via `POWER_BI_CLIENT_SECRET` environment variable. |
| `--tenant-id`     | Required, TEXT | Your Azure AD tenant ID. Can be set via `POWER_BI_TENANT_ID` environment variable.                     |
| `--group-id`      | Required, TEXT | The Power BI workspace group ID. Can be set via `POWER_BI_GROUP_ID` environment variable.              |

### Usage Examples

```bash
# List all datasets (using environment variables)
paradime run power-bi-list-datasets

# With explicit credentials
paradime run power-bi-list-datasets \
  --client-id "your_client_id" \
  --client-secret "your_client_secret" \
  --tenant-id "your_tenant_id" \
  --group-id "your_group_id"
```

{% hint style="success" %}
**Sample Output**

```
Power BI refresh started in group 7a76b78b-0000-4cec-8202-648224ab54e2...
2025-09-11 13:36:50,962 - Refreshing Power BI dataset: 0dfed4be-45fjf-4e83-90d7-497dcbefdc5f
```

{% endhint %}

## Dataset Status Reference

Understanding the refresh capabilities and status indicators:

### Refresh States

* ✅ Refreshable: Dataset can be refreshed programmatically
* ❌ Not Refreshable: Dataset cannot be refreshed (e.g., streaming datasets, live connections)

## Important Notes

* Parallel Execution: Multiple datasets refresh simultaneously for efficiency
* Authentication: Uses Azure AD service principal authentication
* Workspace Permissions: Service principal must have workspace access
* Refresh Limits: Subject to Power BI capacity and refresh quotas
* Timeout Handling: Individual dataset refreshes timeout after 60 seconds for triggering
* Dataset Identification: Use exact dataset names from your Power BI workspace

## Environment Variable Reference

| Environment Variable                | Description                                  |
| ----------------------------------- | -------------------------------------------- |
| `POWER_BI_CLIENT_ID`                | Azure AD application client ID               |
| `POWER_BI_CLIENT_SECRET`            | Azure AD application client secret           |
| `POWER_BI_TENANT_ID`                | Azure AD tenant ID                           |
| `POWER_BI_GROUP_ID`                 | Power BI workspace group ID                  |
| `POWER_BI_REFRESH_REQUEST_BODY_B64` | Base64 encoded refresh parameters (optional) |

## Troubleshooting

<details>

<summary>Authentication Errors</summary>

Ensure your Azure AD application has proper permissions:

```bash
# Check if credentials are valid by listing datasets first
paradime run power-bi-list-datasets
```

</details>

<details>

<summary>Dataset Not Found</summary>

Use the list command to find exact dataset names:

```bash
paradime run power-bi-list-datasets
```

</details>

<details>

<summary>Insufficient Permissions</summary>

Service principal needs at least "Contributor" role in the Power BI workspace.

</details>

<details>

<summary>Non-Refreshable Datasets</summary>

Some dataset types cannot be refreshed via API. Check the dataset type in Power BI service.

</details>

## Workflow Integration

These Microsoft Power BI CLI commands are designed to integrate seamlessly into your data pipeline workflows. Common use cases include:

1. **Post-dbt Refresh**: Trigger Microsoft Power BI refreshes after dbt model runs complete
2. **Scheduled Data Updates**: Automate regular refresh cycles for critical dashboards
3. **CI/CD Integration**: Include Microsoft Power BI refreshes in your deployment pipelines
4. **Resource Discovery**: Use list commands to programmatically discover available workbooks and data sources

For more information about integrating Tableau refreshes into your Paradime workflows, see the [Bolt Schedules documentation.](/app-help/documentation/bolt.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.paradime.io/app-help/developers/paradime-cli/microsoft-power-bi-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
