Reputation: 611
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
Upvotes: 0
Views: 1194
Reputation: 23111
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
Upvotes: 1