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-pluginVerified import paths — ran on the pinned version, not inferred.
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.
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.
When creating or editing the Airflow connection, select 'Generic' for Connection Type and populate 'Login', 'Password', and 'Extra' exactly as specified.
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.
If intermittent authentication errors occur despite correct configuration, try clearing the Airflow worker's token cache or restarting the Airflow worker processes.