Provider package teserak-airflow-providers-teams for Apache Airflow
Project description
teserak-airflow-providers-teams
Provider package for Microsoft Teams integration with Apache Airflow.
Installation
pip install teserak-airflow-providers-teams
Requirements
- Apache Airflow >= 2.11.0
- Python >= 3.10
Connection Setup
Configure an Airflow connection of type teams:
| Field | Description |
|---|---|
| Connection Id | e.g. teams_default |
| Connection Type | teams |
| Host | (leave empty) |
| Extra | {"webhook_url": "https://...webhook.office.com/..."} |
You can also pass the webhook_url directly to the hook/operator without a connection.
Teams uses Incoming Webhooks — create one via:
- Microsoft Teams: Apps → Incoming Webhooks → configure for a channel
- Power Automate Workflows (recommended, replaces older Office 365 connectors)
Usage
Hook
from teserak.airflow.providers.teams.hooks.teams_webhook import TeamsWebhookHook
from teserak.airflow.providers.teams.notifications.adaptive_card import (
AdaptiveCard,
TextBlock,
build_success_card,
)
hook = TeamsWebhookHook(
teams_conn_id="teams_default",
message="DAG finished successfully!",
)
hook.execute()
# With Adaptive Card
card = build_success_card(
dag_id="my_dag",
task_id="my_task",
execution_date="2024-01-15T10:30:00Z",
log_url="https://airflow.example.com/log",
)
hook = TeamsWebhookHook(teams_conn_id="teams_default", card=card)
hook.execute()
Operator
from teserak.airflow.providers.teams.operators.teams_webhook import TeamsWebhookOperator
notify = TeamsWebhookOperator(
task_id="send_teams_message",
teams_conn_id="teams_default",
message="Pipeline {{ dag.dag_id }} finished at {{ ts }}",
)
Notifier (on_failure_callback / on_success_callback)
from teserak.airflow.providers.teams.notifications.teams import TeamsNotifier
from teserak.airflow.providers.teams.notifications.adaptive_card import (
build_failure_card,
build_success_card,
)
with DAG(
dag_id="my_pipeline",
on_failure_callback=TeamsNotifier(
teams_conn_id="teams_default",
card=build_failure_card(
dag_id="my_pipeline",
log_url="https://airflow.example.com/log",
),
),
on_success_callback=TeamsNotifier(
teams_conn_id="teams_default",
card=build_success_card(
dag_id="my_pipeline",
log_url="https://airflow.example.com/log",
),
),
):
...
You can also use a plain text message instead of a card:
with DAG(
dag_id="my_pipeline",
on_failure_callback=TeamsNotifier(
teams_conn_id="teams_default",
text="DAG {{ dag.dag_id }} failed at {{ ts }}!",
),
):
...
Ready-made Success / Failure Cards
from teserak.airflow.providers.teams.notifications.adaptive_card import (
build_success_card,
build_failure_card,
)
# Success card — green header, checkmark, facts with DAG/task/time/log URL
success_card = build_success_card(
dag_id="my_dag",
task_id="my_task",
execution_date="2024-01-15T10:30:00Z",
log_url="https://airflow.example.com/log",
)
# Failure card — red header, cross, exception details
failure_card = build_failure_card(
dag_id="my_dag",
task_id="my_task",
execution_date="2024-01-15T10:30:00Z",
exception="ValueError: unexpected value",
log_url="https://airflow.example.com/log",
)
Adaptive Card Structure
Teams uses Adaptive Cards instead of Discord's Embed objects.
All types are fully typed as TypedDict:
AdaptiveCard— root card (body, actions, $schema, version)TextBlock— text elements with size/weight/color/wrapFactSet/Fact— key-value pairs (analogous to Discord EmbedField)Image— image elementColumnSet/Column— multi-column layoutContainer— grouping container with optional backgroundActionOpenUrl/ActionSet— clickable button actions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file teserak_airflow_providers_teams-1.0.0.tar.gz.
File metadata
- Download URL: teserak_airflow_providers_teams-1.0.0.tar.gz
- Upload date:
- Size: 241.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb5510988551b0ba6bc19353630f384111d8fe67a187bda8260cc37e972201b7
|
|
| MD5 |
09182f7bd930b622991f570fc93e4cf1
|
|
| BLAKE2b-256 |
5340990f01b4b235aebb0b6b6628c0678c4609e517631f9b4f5e8be6947844f5
|
Provenance
The following attestation bundles were made for teserak_airflow_providers_teams-1.0.0.tar.gz:
Publisher:
release.yml on teserak/airflow-teams
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
teserak_airflow_providers_teams-1.0.0.tar.gz -
Subject digest:
cb5510988551b0ba6bc19353630f384111d8fe67a187bda8260cc37e972201b7 - Sigstore transparency entry: 1258560350
- Sigstore integration time:
-
Permalink:
teserak/airflow-teams@0757135f03e12651a49813c8452784df64fda308 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/teserak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0757135f03e12651a49813c8452784df64fda308 -
Trigger Event:
push
-
Statement type:
File details
Details for the file teserak_airflow_providers_teams-1.0.0-py3-none-any.whl.
File metadata
- Download URL: teserak_airflow_providers_teams-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cce0f71d0ea087d2ac810b6b042f42bea913bba3973f15f211762a76851be4dd
|
|
| MD5 |
5695310838f264c1f96bedadabff533a
|
|
| BLAKE2b-256 |
8096bd37223f3a915f496ba89a209529e3534eb63affbd56b34e167c55f72b02
|
Provenance
The following attestation bundles were made for teserak_airflow_providers_teams-1.0.0-py3-none-any.whl:
Publisher:
release.yml on teserak/airflow-teams
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
teserak_airflow_providers_teams-1.0.0-py3-none-any.whl -
Subject digest:
cce0f71d0ea087d2ac810b6b042f42bea913bba3973f15f211762a76851be4dd - Sigstore transparency entry: 1258560401
- Sigstore integration time:
-
Permalink:
teserak/airflow-teams@0757135f03e12651a49813c8452784df64fda308 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/teserak
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@0757135f03e12651a49813c8452784df64fda308 -
Trigger Event:
push
-
Statement type: