Why Get-AzDataFactoryV2PipelineRun doesn't return InProgress pipeline runs?

605 views Asked by At

I am running Azure Function App with the following PowerShell script to get ADF pipeline runs. It is returning all history of pipeline runs, but it is skipping the Active( In Process) run. It is returning Completed/Failed/Cancelled runs only. Microsoft Documentation shows that it should also return InProgress status as well. I triggered the ADF and made sure that it is running and this script only returned runs starting from the last completed run and previous runs, but completely ignored Active/InProgress run.

This is the script:

#Input Parameters

$ResourceGroupName = 'ABC'

$DataFactoryName = 'XYZ'

$before = (get-date).AddDays(1)

$after = (get-date).AddDays(-1)

#Get Pipeline Run History

$runIds = Get-AzDataFactoryV2PipelineRun -DataFactoryName $DataFactoryName -ResourceGroupName $ResourceGroupName  -LastUpdatedAfter $after -LastUpdatedBefore $before

#Return all Retrieved Statuses 

$runIds | ForEach-Object {

    ## Check for all statuses

    Write-Host $_.Status

    Write-Host $_.RunStart

    Write-Host $_.RunEnd

Is this bug or am I missing anything here?

2

There are 2 answers

1
Satya V On

The code looks fine. I tested at my end it works fine. I would give it a shot by widening the timeframe.

$before = (get-date)
$after = (get-date).AddDays(-5)

Also, ensure the pipeline run is not getting completed before the execution of the script.

0
Adam Hamroyev On

I figured out the issue. The issue was data object it was returning was sorted different that I expected. Because, Active Pipeline Runs have null RunEnd , it was putting Active Pipelines at the end of the returned rows. So, it was showing all previous runs sorted from most recent to previous ones (sorted desc) but then it at the end it was returning Active runs from most recent to previous ones again.