如何从CI / CD管道监视adf管道

时间:2019-09-24 09:43:27

标签: azure-devops continuous-integration azure-pipelines azure-data-factory

我有一条CD管道,它触发了一个天蓝色的数据工厂(adf)管道,但它(CD管道)直到(adf)管道完成才等到下一个任务。我想知道CD管道中是否有任何内置功能,通过它们我可以触发和监视adf管道。

因此,我希望得到的结果是CD管道应先等待adf管道完成,然后再继续执行CD管道中的下一个任务。

1 个答案:

答案 0 :(得分:1)

您可以使用Azure DevOps中的以下Powershell脚本。

$resourceGroupName  = "yourresourcegroup"
$DataFactoryName    = "yourdatafactory"
$pipelineName       = "yourpipeline"
$pollFrequency      = 1

$executionId = Invoke-AzDataFactoryV2Pipeline -ResourceGroupName $resourceGroupName -DataFactoryName $DataFactoryName -PipelineName $pipelineName

$runStatus = (Get-AzDataFactoryV2PipelineRun -ResourceGroupName $resourceGroupName -DataFactoryName $DataFactoryName -PipelineRunId $executionId).Status
While ($runStatus -eq 'InProgress') {

    Write-Host ("Pipeline {0} in progress" -f $pipelineName)
    Start-Sleep $pollFrequency

    $runStatus = (Get-AzDataFactoryV2PipelineRun -ResourceGroupName $resourceGroupName -DataFactoryName $DataFactoryName -PipelineRunId $executionId).Status
}

Write-Host ("Pipeline {0} finished with status {1}" -f $pipelineName, $runStatus)