Registry / aws / airflow-powerbi-plugin

airflow-powerbi-plugin

JSON →
library1.0.1pypypiunverified

The airflow-powerbi-plugin, currently at version 1.0.1, is an Apache Airflow plugin designed to automate the refresh of Microsoft Power BI datasets. It provides a custom operator that supports Service Principal Name (SPN) authentication and includes logic to check for existing refreshes before triggering new ones. The project maintains an active release cadence, with updates focused on enhancing Power BI integration within Airflow workflows.

pip install airflow-powerbi-plugin
INSTALL
IMPORT
SIG · AIRFLOW-POWERBI-PL
A
airflow-powerbi-plugin
awspythonv1.0.1
Install
1.5s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 17.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PowerBIDatasetRefreshOperator
from airflow_powerbi_plugin import PowerBIDatasetRefreshOperator
from airflow_powerbi_plugin.operators.powerbi import PowerBIDatasetRefreshOperator

This quickstart demonstrates how to set up a DAG to refresh a Power BI dataset using the `PowerBIDatasetRefreshOperator`. Before running, ensure you have: 1. **Installed the plugin**: `pip install airflow-powerbi-plugin` 2. **Configured an Airflow Connection**: Create a Generic Airflow connection with `Conn Id`: `powerbi_default_conn`. Set `Conn Type`: `Generic`. In `Login` provide your Service Principal's Client ID (e.g., `os.environ.get('POWERBI_CLIENT_ID')`), in `Password` your Client Secret (e.g., `os.environ.get('POWERBI_CLIENT_SECRET')`), and in `Extra` add `{"tenantId": "YOUR_TENANT_ID"}` (e.g., `{"tenantId": "` + `os.environ.get('POWERBI_TENANT_ID')` + `"}`). 3. **Power BI Permissions**: Ensure your Service Principal has 'Contributor' role in the Power BI workspace.

import os from datetime import datetime from airflow import DAG from airflow_powerbi_plugin.operators.powerbi import PowerBIDatasetRefreshOperator with DAG( dag_id='powerbi_dataset_refresh_example', start_date=datetime(2023, 1, 1), schedule_interval=None, catchup=False, tags=['powerbi', 'example'] ) as dag: refresh_powerbi_dataset = PowerBIDatasetRefreshOperator( task_id='refresh_powerbi_dataset', dataset_id=os.environ.get('POWERBI_DATASET_ID', 'YOUR_DATASET_ID'), group_id=os.environ.get('POWERBI_WORKSPACE_ID', 'YOUR_WORKSPACE_ID'), powerbi_conn_id='powerbi_default_conn', # This connection must be configured in Airflow wait_for_termination=True, timeout=3600, # 1 hour timeout for refresh check_interval=30 # Check status every 30 seconds )
Debug
Known issues
gotchaThe plugin relies on Service Principal (SPN) authentication for Power BI. Correct configuration in Azure AD (Client ID, Client Secret, Tenant ID) and granting 'Contributor' role to the Service Principal in the Power BI workspace are critical. Incorrect permissions or expired secrets will lead to authentication failures.
fix
Verify Azure AD app registration for Client ID, Client Secret validity, and API permissions (e.g., `Dataset.ReadWrite.All`). Ensure the Service Principal is added as a 'Contributor' in the target Power BI workspace. Regenerate client secret if expired or suspected compromised.
affects: All
gotchaDue to limitations in Airflow plugins regarding custom connection forms, you must use a 'Generic' connection type in Airflow for Power BI. The Client ID goes into 'Login', Client Secret into 'Password', and the Tenant ID must be passed as JSON in the 'Extra' field like `{"tenantId": "YOUR_TENANT_ID"}`.
fix
When creating or editing the Airflow connection, select 'Generic' for Connection Type and populate 'Login', 'Password', and 'Extra' exactly as specified.
affects: All
gotchaThere are reports of the PowerBIDatasetRefreshOperator (or similar Power BI operators) sometimes failing in Airflow even when the Power BI dataset refresh itself succeeds. This can indicate a race condition or an issue with how Airflow polls for the refresh status.
fix
Ensure `wait_for_termination=True` is set on the operator. Consider increasing `timeout` and `check_interval` parameters if refreshes are long-running. Monitor Airflow worker logs for any token caching issues and restart workers if necessary.
affects: All
gotchaAirflow workers can sometimes cache authentication tokens incorrectly, especially when multiple DAGs use the same connection, leading to intermittent authentication failures for Power BI tasks.
fix
If intermittent authentication errors occur despite correct configuration, try clearing the Airflow worker's token cache or restarting the Airflow worker processes.
affects: All
Upgrade
Version history
1.0.1latest on PyPI · released Sep 17, 2024
Audit
Dependencies
apache-airflowrequiredThis is an Airflow plugin and requires an Apache Airflow environment to function.
Agent activity
60 hits · last 30 days
node
48
OpenAI (training)
2
Perplexity
1
Resources
airflow-powerbi-plugin — pip install airflow-powerbi-plugin · libregistry