簡體   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