Azure逻辑应用程序-如何重新启动失败的操作?

时间:2019-04-10 08:54:53

标签: azure azure-logic-apps azure-iot-hub

我的Azure Logic应用程序中有很多操作失败。 我看到,如果您单击Azure门户上的单个操作,则可以重新启动该操作:

Logic App

是否可以从这些失败的操作中选择 ALL ,然后全部重新运行? 谢谢大家

2 个答案:

答案 0 :(得分:1)

如果您要重新提交失败,成功或仍在运行的一个或多个逻辑应用程序运行,则可以从运行仪表板批量重新提交逻辑应用程序。

enter image description here

enter image description here

关于如何使用此功能,您可以参考本文:Monitor logic apps with Azure Monitor logs。在图块View logic app run information下,您可以找到重新提交说明。

答案 1 :(得分:1)

作为从运行仪表板批量重新提交逻辑应用程序的替代方法,您可以使用 PowerShell 命令。看看下面的脚本,它可以自动列出失败的逻辑应用程序运行识别触发器动作负责和重新启动应用程序 通过输入 ResourceGroupName。 您可以根据需要更改其中的一些部分。 (跳过交互并重新启动应用程序)我只是为了理解而展示它。

<块引用>

使用: Get-AzLogicApp、Get-AzLogicAppRunHistory、 Get-AzLogicAppRunAction、Get-AzLogicAppTrigger 和 Start-AzLogicApp cmdlet。

使用 Az PowerShell 6.2 模块的脚本:Az.LogicApp [复制下面的文件,说 restart.ps1 并运行] 确保将 $rg 分配给实际的 AzResourceGroup姓名

$rg = "MyResourceGrp"

#get logic apps
$logicapps = Get-AzLogicApp -ResourceGroupName $rg

Write-Host "logicapps:" -ForegroundColor "Yellow" 
write-output $logicapps.Name

#list all logicapp runs failed
$failedruns = @(foreach($name in $logicapps.Name){

    Get-AzLogicAppRunHistory -ResourceGroupName $rg -Name $name | Where {$_.Status -eq 'Failed'}
   
})

Write-Host "failedruns:" -ForegroundColor "Yellow" 
Write-Output $failedruns.Name | select -Unique
Write-Host "failedruns: LogicAppNames" -ForegroundColor "Yellow" 
Write-Output $failedruns.Workflow.Name | select -Unique

#list all logicappRunsActions failed

foreach($i in $logicapps){

    foreach($y in $failedruns){

        if ($i.Version -eq $y.Workflow.Name) {
            $resultsB = Get-AzLogicAppRunAction -ResourceGroupName $rg -Name $i.Name -RunName $y.Name -FollowNextPageLink | Where {$_.Status -eq 'Failed'}
        }
    }
}


foreach($item in $resultsB){
    Write-Host "Action:" $item.Name " " -NoNewline "Time:" $item.EndTime 
    Write-Output " "
}


#get logicapp triggers

foreach($ii in $logicapps){

    foreach($yy in $failedruns){

        if ($ii.Version -eq $yy.Workflow.Name) {
            $triggers = Get-AzLogicAppTrigger -ResourceGroupName $rg -Name $ii.Name
        }

    
    }
}

Write-Host "triggers:" -ForegroundColor "Yellow" 
Write-Output $triggers.Name

#start logic apps with triggers
Write-Host "Starting logic apps....." -ForegroundColor "green"

foreach($p in $logicapps){

    foreach($tri in $triggers){

        if ($p.Version -eq $triggers.Workflow.Name) {
            Start-AzLogicApp -ResourceGroupName $rg -Name $p.Name -TriggerName $tri.Name
        }
    }
}


$verify = Read-Host "Verify ruuning app? y or n"

if ($verify -eq 'y') {

    $running = @(foreach($name2 in $logicapps.Name){

        Get-AzLogicAppRunHistory -ResourceGroupName $rg -Name $name2 | Where {$_.Status -eq 'Running' -or $_.Status -eq 'Waiting'}
    })
    Write-Host $running
    
}

else {
    Write-Host "Bye!"
}

enter image description here

虽然我的LogicApp又失败了,但是可以看到是脚本及时触发的

enter image description here

enter image description here

注意:如果您的逻辑应用触发器需要输入或操作(与重复或计划不同),请进行相应的编辑或更改,以成功执行 Start-AzLogicApp 命令。

如果您只想在当前启用的应用程序上运行此命令,我在这里考虑启用所有逻辑应用程序(使用 -State Enabled)参数 Get-AzLogicApp 命令。

示例:Get-AzLogicApp -ResourceGroupName "rg" | where {$_.State -eq 'Enabled'}

2.您还可以尝试在工作流中设置触发器的高级设置。例如重试策略。

enter image description here

您可以指定它以自定义时间间隔重试,以防因间歇性问题而失败。

enter image description here

您可以submit一个反馈或Upvote一个类似的Feedback : ability-to-continue-from-a-particular-point-as-in

参考:help topics for the Logic Apps cmdlets

相关问题