Forum Discussion

mmmall's avatar
mmmall
Regular Visitor
9 months ago
Solved

Airflow Job: Run a DAG using API

Hi! We're using the Airflow Job in Fabric.

 

We need to trigger a DAG when a specific event (webhook) happens. For that, we should use the Airflow Job in the Fabric API.

 

I haven't been successful with this. I see the documentation is very recent (https://learn.microsoft.com/en-us/fabric/data-factory/apache-airflow-jobs-api-capabilities). Could someone kindly share a curl command or similar that can trigger a DAG in my Airflow Job in Fabric?

  • 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

13 Replies

  • v-achippa's avatar
    v-achippa
    Community Support

    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:

     

    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

    • mmmall's avatar
      mmmall
      Regular Visitor

      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-achippa's avatar
        v-achippa
        Community 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