Microsoft Power BI Operators¶
Microsoft Power BI, is a unified, scalable platform for self-service and enterprise business intelligence(BI).
Prerequisite Tasks¶
To use these operators, you must do a few things:
Create necessary resources using AZURE PORTAL or AZURE CLI.
Install API libraries via pip.
pip install 'apache-airflow[azure]'Detailed information is available Installation of Airflow®
PowerBIDatasetRefreshOperator¶
To trigger a refresh for the specified dataset from the specified workspace, use the PowerBIDatasetRefreshOperator.
refresh_powerbi_dataset = PowerBIDatasetRefreshOperator(
conn_id="powerbi_default",
task_id="refresh_powerbi_dataset",
dataset_id=DATASET_ID,
group_id=GROUP_ID,
check_interval=30,
timeout=120,
request_body={
"type": "full",
"retryCount": 3,
"commitMode": "transactional",
"notifyOption": "MailOnFailure",
},
)
Durable execution¶
The operator is durable by default: it starts the refresh from the worker and keeps its id in the task state store before it defers. A retry reconnects to a refresh that is still in progress and does not start a new one once it has completed. A refresh that failed, or that is no longer in the dataset’s refresh history, is started again. Durable execution requires Airflow 3.3 or newer.
Two things differ from earlier versions of the provider when the operator is durable:
The refresh is started by the worker, so the workers need network access to
api.powerbi.comtoo. The triggerer still polls the refresh.The refresh is not cancelled when polling it fails, so the retry can reconnect to it.
Set durable=False to keep the earlier behaviour: the trigger starts the refresh, so only the triggerer
talks to Power BI, every try starts a new refresh, and it is cancelled when polling fails. Below Airflow
3.3 the operator behaves as with durable=False.
PowerBIDatasetListOperator¶
To list all available and discoverable datasets from the specified workspace, use the PowerBIDatasetListOperator.
get_powerbi_dataset_list = PowerBIDatasetListOperator(
conn_id="powerbi_default",
task_id="get_powerbi_dataset_list",
group_id=GROUP_ID,
timeout=120,
)
PowerBIWorkspaceListOperator¶
To list all available and discoverable workspaces for the tenant, use the PowerBIWorkspaceListOperator.
get_powerbi_workspace_list = PowerBIWorkspaceListOperator(
conn_id="powerbi_default",
task_id="get_powerbi_workspace_list",
timeout=120,
)
Reference¶
For further information, look at: