Submitting configuration when triggering an Airflow DAG: What does it do?

Viewed 1580

When you trigger an Airflow DAG either through the UI (see screenshot) or the API (https://airflow.apache.org/docs/stable/rest-api-ref.html), you have the option of submitting a JSON configuration. However the usefulness of this isn't clearly documented as far as I can tell. I have two basic questions:

  • Is this intended for free-form configuration settings at the application level, or is this only for Airflow configuration variables?
  • If this is for free-form configuration settings, how (in my code) can I access whatever configuration was passed when the DAG was triggered?

Here is the screenshot where you can provide configuration when triggering a DAG:

enter image description here

1 Answers

Yes it is intended for Application level configuration.

Example -

{"appConfig":"Test"}

To read it in your DAG

def read_app_configuration(**kwargs):
    print("Read App Config - Task : Start")
    dag_run = kwargs['dag_run']
    region = kwargs['dag_run'].conf.get('appConfig')

Related