Forum Discussion
Airflow Job: Run a DAG using API
- 8 months ago
Hi mmmall,
Thank you for the response. Based on the screenshot here looks like the Fabric portal is calling the Airflow API using a session cookie, not a bearer token. Because of this internal authentication flow, it is not possible to reproduce the same call externally using a client-credentials token or any token we generate ourselves.
Currently fabric does not provide a public API to directly trigger a DAG inside an Apache Airflow Job, that is why your direct API calls fail even with a valid token.
The only supported approach is to trigger a Fabric item for example like a Notebook or Pipeline using the Fabric REST API and run the logic there.
Thanks and regards,
Anjan Kumar Chippa
Hi mmmall,
Thank you for reaching out to Microsoft Fabric Community.
In Fabric, the supported way to trigger a DAG or job from an external webhook is through the Fabric REST API. Please follow below steps:
- Create an Azure AD app (service principal) and grant it Fabric execute permission for example Item.Execute.All or the specific item execute scope and add it to your Fabric workspace.
- Then from the webhook handler use client credentials to get a Fabric token, for example like below:
curl -s -X POST "https://login.microsoftonline.com/{TENANT_ID}/oauth2/v2.0/token"
-H "Content-Type: application/x-www-form-urlencoded"
-d "grant_type=client_credentials&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}&scope=https://api.fabric.microsoft.com/.default" -
Trigger the Fabric item Run On Demand Item Job API to start the Airflow Job:
curl -i -X POST "https://api.fabric.microsoft.com/v1/workspaces/{WORKSPACE_ID}/items/{ITEM_ID}/jobs/instances?jobType=DefaultJob"
-H "Authorization: Bearer {ACCESS_TOKEN}"
-H "Content-Type: application/json"
-d '{ "executionData": { "triggeredBy": "webhook", "webhookPayload": {"eventId":"12345"} } }'
Replace the required values, with correct Id's.
If successful you will get 202 Accepted and a job instance id.
Thanks and regards,
Anjan Kumar Chippa
Hi Anjan, thanks for your input.
I can find the Airflow Job item using fabric API:
curl -X GET "https://api.fabric.microsoft.com/v1/workspaces/$FABRIC_WORKSPACE_ID/items/$FABRIC_AIRFLOW_JOB_ID" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json"
{"id":"99999-9999-9999-9999-9999999","type":"ApacheAirflowJob","displayName":"dev_airflow","description":"Airflow","workspaceId":"99999-9999-9999-9999-9999999"}
But subsequent API calls such as the one you mentioned (Trigger the Fabric item Run On Demand Item Job API to start the Airflow Job) always return The requested job type is invalid. I also noticed we would need to mention the DAG name (e.g. dag_run_ingestion) somewhere. I have tried multiple different jobType's, but it always returns job type is invalid.
curl -i -X POST "https://api.fabric.microsoft.com/v1/workspaces/$FABRIC_WORKSPACE_ID/items/$FABRIC_AIRFLOW_JOB_ID/jobs/instances?jobType=DefaultJob /
-H "Authorization: Bearer $ACCESS_TOKEN" /
-H "Content-Type: application/json" /
-d '{ "executionData": { "triggeredBy": "webhook", "webhookPayload": {"eventId":"12345"} } }'
HTTP/2 400
cache-control: no-store, must-revalidate, no-cache
pragma: no-cache
content-type: application/json; charset=utf-8
x-ms-public-api-error-code: InvalidJobType
strict-transport-security: max-age=31536000; includeSubDomains
x-frame-options: deny
x-content-type-options: nosniff
requestid: 9999999-9999-9999-9999-9999999999
access-control-expose-headers: RequestId
request-redirected: true
home-cluster-uri: https://wabi-us-north-central-j-primary-redirect.analysis.windows.net/
date: Thu, 30 Oct 2025 19:42:45 GMT
{"requestId":"9999999-9999-9999-9999-9999999999","errorCode":"InvalidJobType","message":"The requested job type is invalid"}
Would you know:
- If this works with Fabric Airflow Job (it differs from Azure manager airflow)?
- If the Airflow Job is in Starter Pool (Auto pausing), will it trigger a start for the Airflow Job, wait and trigger the DAG run?
- If this is the proper way to trigger an Airflow Job DAG?
- v-achippa9 months agoCommunity Support
Hi mmmall,
Fabric’s Run On Demand Item Job API currently does not accept a jobType that directly starts a DAG inside an ApacheAirflowJob item, that is why you are getting the InvalidJobType error.
To trigger a DAG run, you have two supported options:
- Call the Airflow REST API directly if the airflow webserver endpoint is reachable and supports token or basic authentication.
- Trigger a Fabric item for example a notebook or data pipeline via the Fabric REST API, and have that item trigger the DAG from inside Fabric.
Please refer below document for your reference:
https://learn.microsoft.com/en-us/fabric/data-factory/apache-airflow-jobs-api-capabilities
Thanks and regards,
Anjan Kumar Chippa
- v-achippa9 months agoCommunity Support
Hi mmmall,
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution I have provided for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa
- mmmall9 months agoRegular Visitor
Hello Anjan,
When grabbing the powerBIAccessToken from Developer tools - Console, we are able directly use the Airflow API, in example below simply to list all DAGs:
curl -X 'GET' 'https://aeexxxxxxxxxxxxxx.northcentralus.airflow.svc.datafactory.azure.com/api/v1/dags?limit=100&only_active=true' \ -H 'accept: application/json' \ -H "Authorization: Bearer [TOKEN_GOES_HERE]"But we were unable to generate a token that behaves the same way as the powerBIAccessToken. We always get a 302 Found (which sounds like a redirect to login page) when using our own token. Below is a sample of how we tried to generate a token, using a client_id & client_secret (App registration) that has permissions in below image as per documentation.
import msal tenant_id = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" client_id = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx" client_secret = "G63xxxxxxx" authority = f"https://login.microsoftonline.com/{tenant_id}" app = msal.ConfidentialClientApplication( client_id, authority=authority, client_credential=client_secret ) scopes = ["https://analysis.windows.net/powerbi/api/.default"] token_response = app.acquire_token_for_client(scopes=scopes) print("Bearer token:", token_response["access_token"])