如何检查以管道名称运行的最新数据工厂管道的当前状态?

时间:2020-05-27 21:22:07

标签: azure-data-factory azure-data-factory-2

是否可以使用.NET SDK检查以管道名称运行的最新数据工厂管道的当前状态?这是我现在尝试的:

             using (var client = new DataFactoryManagementClient(cred) {SubscriptionId = subscriptionId})
            {
                RunQueryFilter pipeline = new RunQueryFilter("PipelineName", "Equals", new List<string> { "Pipeline" });                

                var before = DateTime.UtcNow;
                var after = before.AddHours(-24);
                var param = new RunFilterParameters(after, before, null, new List<RunQueryFilter> { pipeline }, null);
                PipelineRunsQueryResponse pipelineResponse = client.PipelineRuns.QueryByFactory(
                                                                        resourceGroup,
                                                                        dataFactoryName, param
                                                                    );



            }

How do I get latest run id?

1 个答案:

答案 0 :(得分:0)

想通了-

using (var client = new DataFactoryManagementClient(cred) {SubscriptionId = subscriptionId})
            {
                RunQueryFilter pipeline = new RunQueryFilter("PipelineName", "Equals", new List<string> { "Pipeline" });                
                var pipelineRuns = new RunQueryOrderBy("RunEnd", "DESC");
                var before = DateTime.UtcNow;
                var after = before.AddHours(-24);
                var param = new RunFilterParameters(after, before, null, new List<RunQueryFilter> { pipeline }, new List<RunQueryOrderBy> { pipelineRuns });
                PipelineRunsQueryResponse pipelineResponse = client.PipelineRuns.QueryByFactory(
                                                                        resourceGroup,
                                                                        dataFactoryName, param
                                                                    );

                var runId = pipelineResponse?.Value?[0]?.RunId;

            }