简体   繁体   中英

How to get automatically triggered Azure Data Factory pipeline run status

I am using the following Python code (mostly got from Stackoverflow) to get a specific ADF pipeline run status successfully. This is returning manually triggered runs. That is from tab 1 in the image below.

However I want to get the runs in tab 2. The code below is not able to do that.

What do I need to add to get "automatically triggered" runs from tab2? I have a trigger named "DailyTrigger" on the pipeline.

在此处输入图像描述

Thanks!

def get_triggered_pipeline_run_status_history_df(adf_client,resource_group_name,days_ago,adf_pipeline_name):
    filter_params = RunFilterParameters(last_updated_after=datetime.now(timezone.utc) - timedelta(days_ago),last_updated_before=datetime.now(timezone.utc) + timedelta(days_ago))
    for adf_name in get_subscription_data_factory_list(adf_client,resource_group_name):
        adf_run_history = adf_client.pipeline_runs.query_by_factory(resource_group_name,adf_name,filter_params)
        if len(adf_run_history.value) > 0:
            latest_pipeline_runids_df = __get_latest_pipeline_runid__(adf_run_history.value,adf_pipeline_name)
            for row in latest_pipeline_runids_df.itertuples():
                pipeline_run = adf_client.pipeline_runs.get(resource_group_name, adf_name, row.latest_runid)         
                if str(pipeline_run.pipeline_name).lower() == str(adf_pipeline_name).lower():
                    query_response = adf_client.activity_runs.query_by_pipeline_run(resource_group_name, adf_name, row.latest_runid,filter_params)
                    df = __enumerate_print_run_activities__(query_response.value,adf_name,pipeline_run.pipeline_name,pipeline_run.run_end,pipeline_run.status)
            return df  

According to my understanding you want to get trigger run history. If so, you can use the rest API Trigger Runs - Query By Factory to implement it.

For example

adf_client = DataFactoryManagementClient(credentials, subscription_id)
filter_params = RunFilterParameters(last_updated_after=datetime.now(timezone.utc) - timedelta(7),last_updated_before=datetime.now(timezone.utc) + timedelta(7),filters=[
  {  
    "operand": "TriggerName",
    "operator": "In",
    "values": [
        "<your trigger name>"
    ]
  }
])

 res = adf_client.trigger_runs.query_by_factory(resource_group_name,adf_name,filter_params)

// process the result according to your need

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM