Apache Airflow Asana Provider
The `apache-airflow-providers-asana` package, currently at version 2.11.3, provides operators and hooks to seamlessly integrate Apache Airflow with Asana. It enables users to programmatically manage Asana tasks (create, update, delete, find) and projects within Airflow workflows. As a community-managed provider, it's independently versioned and released from core Apache Airflow, offering flexible integration with the Asana work management tool.
Common errors
-
ModuleNotFoundError: No module named 'airflow.providers.asana.operators.asana'
cause The `apache-airflow-providers-asana` package is not installed or not accessible to the Airflow component trying to run the DAG (e.g., scheduler, worker).fixRun `pip install apache-airflow-providers-asana`. If using Docker/Kubernetes, ensure the installation is part of your Airflow image build process and is present in all Airflow containers (scheduler, webserver, workers). -
airflow.exceptions.AirflowException: The Asana connection 'asana_default' was not found.
cause The Airflow connection ID specified in `asana_conn_id` does not exist or is misspelled in the Airflow UI.fixNavigate to `Admin -> Connections` in the Airflow UI and create a new connection. Set the `Conn Id` to match the one used in your operator (e.g., `asana_default`), choose 'Asana' as the `Conn Type`, and provide your Asana Personal Access Token in the 'Login' field. -
asana.error.NoAuthorizationError: Not Authorized
cause The Asana Personal Access Token provided in the Airflow connection is invalid, expired, or has insufficient permissions for the requested operation.fixVerify the Asana Personal Access Token in your Airflow connection (Admin -> Connections) is correct and active. Check your Asana account for token validity and ensure it has the necessary permissions for the tasks your DAG attempts to perform. Regenerate the token if necessary.
Warnings
- breaking Provider versions are tied to minimum Airflow versions. For example, provider `2.0.0` required Airflow `2.2.0+`, while the current `2.11.x` series requires Apache Airflow `>=2.11.0`.
- deprecated The generic `AsanaOperator` class is deprecated. Users should use specific operators for distinct actions like creating, updating, deleting, or finding tasks.
- gotcha The Asana provider package must be installed on all Airflow components (scheduler, webserver, and workers) for it to function correctly across the entire Airflow deployment.
- gotcha Authentication to Asana requires an Asana Personal Access Token configured in an Airflow connection. Incorrectly configured connections will lead to authentication failures.
Install
-
pip install apache-airflow-providers-asana
Imports
- AsanaCreateTaskOperator
from airflow.providers.asana.operators.asana import AsanaCreateTaskOperator
- AsanaUpdateTaskOperator
from airflow.providers.asana.operators.asana import AsanaUpdateTaskOperator
- AsanaDeleteTaskOperator
from airflow.providers.asana.operators.asana import AsanaDeleteTaskOperator
- AsanaFindTaskOperator
from airflow.providers.asana.operators.asana import AsanaFindTaskOperator
- AsanaHook
from airflow.providers.asana.hooks.asana import AsanaHook
- AsanaOperator
from airflow.providers.asana.operators.asana import AsanaOperator
from airflow.providers.asana.operators.asana import AsanaCreateTaskOperator # or other specific operators
Quickstart
import os
from datetime import datetime
from airflow import DAG
from airflow.providers.asana.operators.asana import AsanaCreateTaskOperator
# Configure your Asana Personal Access Token in an Airflow connection
# with Conn Id 'asana_default' and 'Personal Access Token' as Login.
# For production, consider using Airflow Secrets Backend.
# Example values for workspace_id and project_id below are placeholders.
# Replace 'your_workspace_id' and 'your_project_id' with actual Asana GIDs.
ASANA_CONN_ID = 'asana_default'
ASANA_WORKSPACE_GID = os.environ.get('ASANA_WORKSPACE_GID', 'your_workspace_id') # Asana Workspace GID
ASANA_PROJECT_GID = os.environ.get('ASANA_PROJECT_GID', 'your_project_id') # Asana Project GID
with DAG(
dag_id='asana_task_creation_example',
start_date=datetime(2023, 1, 1),
schedule_interval=None,
catchup=False,
tags=['asana', 'example'],
) as dag:
create_asana_task = AsanaCreateTaskOperator(
task_id='create_new_asana_task',
asana_conn_id=ASANA_CONN_ID,
name='Airflow-created Task',
task_parameters={
'workspace': ASANA_WORKSPACE_GID,
'projects': [ASANA_PROJECT_GID],
'notes': 'This task was created by an Apache Airflow DAG.',
'due_on': '2026-04-30' # Example due date
}
)