我使用 Azure Data Factory UI 创建了一个 ADF 管道,每天触发一次运行。是否有办法使用.NET SDK获取最新的管道运行id &;监控该运行? 请提供一个控制台应用程序,对现有的ADF管道运行进行同样的操作?
这是我试过的,使用.NET SDK创建管道,并监控运行(https:/docs.microsoft.comen-usazuredata-factoryquickstart-creative-data-factory-dot-net。):
static async Task Main(string[] args)
{
// Authenticate and create a data factory management client
var context = new AuthenticationContext("https://login.windows.net/" + tenantID);
ClientCredential cc = new ClientCredential(applicationId, authenticationKey);
AuthenticationResult result = context.AcquireTokenAsync(
"https://management.azure.com/", cc).Result;
ServiceClientCredentials cred = new TokenCredentials(result.AccessToken);
using (var client = new DataFactoryManagementClient(cred) {
SubscriptionId = subscriptionId
})
{
RunQueryFilter filter1 = new RunQueryFilter("PipelineName", "Equals", new List<string> { "Pipeline" });
DateTime before = DateTime.UtcNow;
DateTime after = before.AddHours(-24);
RunFilterParameters param = new RunFilterParameters(after, before, null, new List<RunQueryFilter> { filter1 }, null);
PipelineRunsQueryResponse pipelineResponse = client.PipelineRuns.QueryByFactory(
resourceGroup,
dataFactoryName, param
);
}
// Monitor the pipeline run
Console.WriteLine("Checking pipeline run status...");
PipelineRun pipelineRun;
while (true)
{
pipelineRun = client.PipelineRuns.Get(
resourceGroup, dataFactoryName, runResponse.RunId);
Console.WriteLine("Status: " + pipelineRun.Status);
if (pipelineRun.Status == "InProgress" || pipelineRun.Status == "Queued")
System.Threading.Thread.Sleep(15000);
else
break;
}
}
但是否可以通过从ADF获取最新的运行ID来监控运行情况?
步骤1,请看 IPipelineRunsOperations.QueryByFactoryWithHttpMessagesAsync。 方法。
步骤2:导航到RunFilterParameters类,你可以找到名为OrderBy的属性。
第三步:找到 RunQueryOrderBy 类,你可以看到它接受2个参数。这里,你可以将它们设置为 RunEnd
和 DESC
.
Step4:得到管道运行列表的第一个元素即可。