We use following line to query azure datafactory pipeline run status (V2 datafactory):
var pipeline = InnerClient.Pipelines.Get(resourceGroupName, dataFactoryName, pipelineName);
DateTime to = DateTime.Now.AddDays(1);
DateTime from = DateTime.Now.AddDays(-14);
var prfp = new RunFilterParameters(from, to);
var response = InnerClient.PipelineRuns.QueryByFactory(resourceGroupName, dataFactoryName, prfp);
var lastRun = response.Value.Where(x => x.PipelineName.Equals(pipelineName, StringComparison.CurrentCultureIgnoreCase) && x.IsLatest.GetValueOrDefault()).OrderByDescending(x => x.LastUpdated).Take(1).SingleOrDefault();
log.LogInformation("Pipeline status is:" + lastRun.Status);
Randomly, we saw that when the pipeline was running, we actually outputted "Succeeded", and another case, it outputted "Failed", when the pipeline was still running. So is there anything wrong with the way we query pipeline status? In 99% cases, the output matches with what is happening in the datafactory, but did trigger problems when the status was retrieved wrongly.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…