ambika-garg / PowerBI_Airflow_Plugin

Apache Airflow Plugin for a Power BI dataset refresh.
4 stars 1 forks source link
apache-airflow powerbi

Apache Airflow Plugin for Power BI Dataset Refresh. 🚀

Introduction

Get ready to enhance your Apache Airflow workflows with a new plugin designed for refreshing Power BI datasets! The plugin contains the custom operator to seamlessly handle dataset refresh and it supports SPN authentication. Additionally, the operator checks for existing refreshes before triggering the new one.

How to Use

Getting Started

To utilize this operator, simply fork the repository locally and you're ready to roll.

Authentication

Before diving in,

Since custom connection forms aren't feasible in Apache Airflow plugins, credentials must be stored in the secret backend. Here's what you need to store:

  1. client_id: The Client ID of your service principal.
  2. client_secret: The Client Secret of your service principal.
  3. tenant_id: The Tenant Id of your service principal.

Operators

PowerBIDatasetRefreshOperator

This operator composes the logic for this plugin. It triggers the Power BI dataset refresh and pushes the details in Xcom. It can accept the following parameters:

Features

Sample DAG to use the plugin.

Ready to give it a spin? Check out the sample DAG code below:

from datetime import datetime

from airflow import DAG
from airflow.operators.bash import BashOperator
from operators.powerbi_refresh_dataset_operator import PowerBIDatasetRefreshOperator

with DAG(
        dag_id='refresh_dataset_powerbi',
        schedule_interval=None,
        start_date=datetime(2023, 8, 7),
        catchup=False,
        concurrency=20,
        tags=['powerbi', 'dataset', 'refresh']
) as dag:

    refresh_in_given_workspace = PowerBIDatasetRefreshOperator(
        task_id="refresh_in_given_workspace",
        dataset_id="<dataset_id",
        group_id="workspace_id",
        force_refresh = False,
        wait_for_termination = False
    )

    refresh_in_given_workspace

Feel free to tweak and tailor this DAG to suit your needs!

🌟 Please feel free to share any thoughts or suggestions you have.