繁体   English   中英

使用 powershell 如何通过运行 ID 在 Azure 数据工厂中重新运行失败的管道?

[英]Using powershell how do you rerun failed pipeline in Azure Data Factory by run ID?

在 Azure 数据工厂中,我需要重新运行大约 4000 多个失败的管道。 可以在 Azure 门户 UI 中执行此操作,但我尝试在 powershell 中自动执行运行-运行过程。

我无法在 powershell 中找到命令/步骤来通过运行 ID 运行失败的管道。

我在寻找相同问题的解决方案时发现了这个问题,所以这是我找到的答案。

如果您想重新运行整个管道并且您不关心它在技术上被数据工厂视为重新运行,您可以使用Get-AzDataFactoryV2PipelineRun cmdlet 获取运行列表,过滤到失败的运行,然后在调用Invoke-AzureRmDataFactoryV2Pipeline使用相同的参数

似乎很快就会更新 cmdlet 以允许真正重新运行(基于有人在 Microsoft 的Visually monitor Azure 数据工厂文档中提出的对这个问题的回应)。

如果您急于能够真正重新运行,那么通过使用一些可选参数调用createRun ,该功能已包含在REST API 中

编辑:这已添加到 2020 年 10 月发布的 Azure PowerShell 模块 v4.8.0 ( docs )。 现在,您可以通过管道运行ID的Invoke-AzDataFactoryV2Pipeline使用cmdlet的-ReferencePipelineRunId有它使用的参数从运行。 您还可以使用-StartFromFailure开关让它只重新运行失败的活动。

我刚刚找到了一个教程Azure 数据工厂:检测和重新运行失败的 ADF 切片,它为您提供了 Powershell 脚本来自动化失败的管道。

Powershell 脚本:

Login-AzureRmAccount
$slices= @()
$tableName=@()
$failedSlices= @()
$failedSlicesCount= @()
$tableNames=@()

$Subscription="Provide Subscription ID"  

  Select-AzureRMSubscription -SubscriptionId  $Subscription    
$DataFactoryName="Provide Data Factory Name"
$resourceGroupName ="Porvide Resource Group Name for Data Factory"

$startDateTime ="2015-05-01" #Start Date for Slices
$endDateTime="2015-08-01" # End Date for Slices


#Get Dataset names in Data Factory - you can exlicitly give a table name using $tableName variable if you like to run only for an individual tablename
$tableNames = Get-AzureRMDataFactoryDataset -DataFactoryName $DataFactoryName -ResourceGroupName $resourceGroupName | ForEach {$_.DatasetName}

$tableNames #lists tablenames

foreach ($tableName in $tableNames)
{
    $slices += Get-AzureRMDataFactorySlice -DataFactoryName $DataFactoryName -DatasetName $tableName -StartDateTime $startDateTime -EndDateTime $endDateTime -ResourceGroupName $resourceGroupName -ErrorAction Stop
}


$failedSlices = $slices | Where {$_.Status -eq 'Failed'}

$failedSlicesCount = @($failedSlices).Count

if ( $failedSlicesCount -gt 0 ) 
{

    write-host "Total number of slices Failed:$failedSlicesCount"
    $Prompt = Read-host "Do you want to Rerun these failed slices? (Y | N)" 
    if ( $Prompt -eq "Y" -Or $Prompt -eq "y" )
    {

        foreach ($failed in $failedSlices)
        {
            write-host "Rerunning slice of Dataset "$($failed.DatasetName)" with StartDateTime "$($failed.Start)" and EndDateTime "$($failed.End)"" 
            Set-AzureRMDataFactorySliceStatus -UpdateType UpstreamInPipeline -Status Waiting -DataFactoryName $($failed.DataFactoryName) -DatasetName $($failed.DatasetName) -ResourceGroupName $resourceGroupName -StartDateTime "$($failed.Start)" -EndDateTime "$($failed.End)" 


        }
    }

}
else
{
    write-host "There are no Failed slices in the given time period."
}

希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM