Apache Airflow Plugin for Microsoft Fabric Plugin. 🚀
Introduction
A Python package that helps Data and Analytics engineers trigger run on demand job items of Microsoft Fabric in Apache Airflow DAGs.
Microsoft Fabric is an end-to-end analytics and data platform designed for enterprises that require a unified solution. It encompasses data movement, processing, ingestion, transformation, real-time event routing, and report building. It offers a comprehensive suite of services including Data Engineering, Data Factory, Data Science, Real-Time Analytics, Data Warehouse, and Databases.
How to Use
Prerequisities
Before diving in,
- The plugin supports the authentication using user tokens. Tenant level admin account must enable the setting Allow user consent for apps. Refer to: Configure user consent
- Create a Microsoft Entra Id app if you don’t have one. Refer to: Doc
- You must have Refresh token.
Since custom connection forms aren't feasible in Apache Airflow plugins, use can use Generic connection type. Here's what you need to store:
Connection Id: Name of the connection IdConnection Type: GenericLogin: The Client ID of your service principal.Password: The refresh token fetched using Microsoft OAuth.Extra: { "tenantId": The Tenant Id of your service principal. }
Operators
FabricRunItemOperator
This operator composes the logic for this plugin. It triggers the Fabric item run and pushes the details in Xcom. It can accept the following parameters:
workspace_id: The workspace Id.item_id: The Item Id. i.e Notebook and Pipeline.fabric_conn_id: Connection Id for Fabric.job_type: "RunNotebook" or "Pipeline".wait_for_termination: (Default value: True) Wait until the run item.timeout: Time in seconds to wait for the pipeline or notebook. Used only ifwait_for_terminationis True.check_interval: Boolean. Number of seconds to wait before rechecking the refresh status.deferrable: Boolean. Use the operator in deferrable mode.
Features
-
Refresh token rotation:
Refresh token rotation is a security mechanism that involves replacing the refresh token each time it is used to obtain a new access token. This process enhances security by reducing the risk of stolen tokens being reused indefinitely.
-
Xcom Integration:
The Fabric run item enriches the Xcom with essential fields for downstream tasks:
run_id: Run Id of the Fabric item.run_status: Fabric item run status.In Progress: Item run is in progress.Completed: Item run successfully completed.Failed: Item run failed.Disabled: Item run is disabled by a selective refresh.
run_location: The location of item run status.
-
External Monitoring link:
The operator conveniently provides a redirect link to the Microsoft Fabric item run.
-
Deferable Mode:
The operator runs in deferrable mode. The operator is deferred until the target status of the item run is achieved.
Sample DAG to use the plugin.
Ready to give it a spin? Check out the sample DAG code below:
from __future__ import annotations
from airflow import DAG
from apache_airflow_microsoft_fabric_plugin.operators.fabric import FabricRunItemOperator
from airflow.utils.dates import days_ago
default_args = {
"owner": "airflow",
"start_date": days_ago(1),
}
with DAG(
dag_id="fabric_items_dag",
default_args=default_args,
schedule_interval="@daily",
catchup=False,
) as dag:
run_notebook = FabricRunItemOperator(
task_id="run_fabric_notebook",
workspace_id="<workspace_id>",
item_id="<item_id>",
fabric_conn_id="fabric_conn_id",
job_type="RunNotebook",
wait_for_termination=True,
deferrable=True,
)
run_notebook
Feel free to tweak and tailor this DAG to suit your needs!
🌟 Please feel free to share any thoughts or suggestions you have.
Release files for apache-airflow-microsoft-fabric-plugin-custom 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| apache_airflow_microsoft_fabric_plugin_custom-1.0.6.tar.gz | 15.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| apache_airflow_microsoft_fabric_plugin_custom-1.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.1 kB
Release files / apache_airflow_microsoft_fabric_plugin_custom-1.0.6.tar.gz
| Download URL | apache_airflow_microsoft_fabric_plugin_custom-1.0.6.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57762ecfd8aa3c5573cd07579fae5b6c776c68bfc9b3537aacb5b2e994c41cbb
|
|
BLAKE2b-256 checksum How to use checksums |
05e15b55e3532cecbd248deb7795d7b8dadb51df09d78378cfa26f4fa679cad7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / apache_airflow_microsoft_fabric_plugin_custom-1.0.6-py3-none-any.whl
| Download URL | apache_airflow_microsoft_fabric_plugin_custom-1.0.6-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e49e29987b931e88e8210304440dc6d99ee1639839506734a56180ae144ef69
|
|
BLAKE2b-256 checksum How to use checksums |
3c0e67ea2e6c85dce6f5254fc330eddb6a7659a411f0ac82f338060134b41b59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|