Apache Airflow Provider(s)
microsoft-azure
Versions of Apache Airflow Providers
apache-airflow-providers-microsoft-azure==12.6.0
Apache Airflow version
3.0.4
Operating System
Debian GNU/Linux 12 (bookworm)
Deployment
Official Apache Airflow Helm Chart
Deployment details
Deployed in AKS using an extended docker image containing authorization logic and extra provider packages.
The KubernetesExecutor is used for running Tasks.
What happened
The MsGraphAsync operator fails to get an connection. It errors out with the following exception.
[2025-08-11, 09:33:08] ERROR - An error occurred: You cannot use AsyncToSync in the same thread as an async event loop - just await the async function directly.: source="airflow.providers.microsoft.azure.triggers.msgraph.MSGraphTrigger"
RuntimeError: You cannot use AsyncToSync in the same thread as an async event loop - just await the async function directly.
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/microsoft/azure/triggers/msgraph.py", line 197 in run
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/microsoft/azure/hooks/msgraph.py", line 403 in run
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/microsoft/azure/hooks/msgraph.py", line 422 in send_request
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/providers/microsoft/azure/hooks/msgraph.py", line 252 in get_conn
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/hooks/base.py", line 64 in get_connection
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/models/connection.py", line 478 in get_connection_from_secrets
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/definitions/connection.py", line 144 in get
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/sdk/execution_time/context.py", line 155 in _get_connection
File "/home/airflow/.local/lib/python3.12/site-packages/airflow/jobs/triggerer_job_runner.py", line 713 in send
File "/home/airflow/.local/lib/python3.12/site-packages/asgiref/sync.py", line 186 in __call__
The dag code:
from datetime import datetime, timedelta
from airflow import DAG
from airflow.providers.microsoft.azure.operators.msgraph import MSGraphAsyncOperator
default_args = {
"start_date": datetime(2025, 1, 1),
"retries": 0,
"retry_delay": timedelta(minutes=5),
}
subscription_id = "placeholder"
resource_group = "rg-fabric"
capacity = "placeholder"
with DAG(
dag_id="get_fabric_capacity",
schedule=None,
default_args=default_args,
catchup=False,
tags=["Fabric"]
) as dag:
get_capacity_details = MSGraphAsyncOperator(
task_id="get_fabric_capacity",
conn_id="FABRIC_CAPACITY",
method="GET",
url=(
"https://management.azure.com"
f"/subscriptions/{subscription_id}"
f"/resourceGroups/{resource_group}"
f"/providers/Microsoft.Fabric"
f"/capacities/{capacity}"
),
query_parameters={"api-version": "2023-11-01"},
response_type="str"
)
What you think should happen instead
The expected behaviour is that the request is made to the API, and a response is shown, either 401 or 200 containing a response body
How to reproduce
Create a dag calling the MSGraphAsyncOperator with an existing connection and run the Dag.
Anything else
No response
Are you willing to submit PR?
Code of Conduct
Apache Airflow Provider(s)
microsoft-azure
Versions of Apache Airflow Providers
apache-airflow-providers-microsoft-azure==12.6.0
Apache Airflow version
3.0.4
Operating System
Debian GNU/Linux 12 (bookworm)
Deployment
Official Apache Airflow Helm Chart
Deployment details
Deployed in AKS using an extended docker image containing authorization logic and extra provider packages.
The KubernetesExecutor is used for running Tasks.
What happened
The MsGraphAsync operator fails to get an connection. It errors out with the following exception.
The dag code:
What you think should happen instead
The expected behaviour is that the request is made to the API, and a response is shown, either 401 or 200 containing a response body
How to reproduce
Create a dag calling the MSGraphAsyncOperator with an existing connection and run the Dag.
Anything else
No response
Are you willing to submit PR?
Code of Conduct