Webhook活动在ADF V2中永久运行

问题描述

我想通过在Power Shell中编写代码的Runbook处理多维数据集,我想从ADF的webhook活动中调用此Runbook,但是此活动一直运行到超时,但是无法完成,但是其处理通过触发运行手册成功多维数据集。为了使它在ADF中成功还是失败,我是否还必须编写一些代码。还是我的配置中缺少其他内容

解决方法

如果您希望ADF等待运行手册完成,那么Webhook活动(就像您正在做的那样)是正确的。但是您的Runbook需要使用$webhookData parameter in the Azure Automation webhook documentation接受callbackUri参数。然后,Runbook需要通过Web调用ADF回调API来使其完成。

另一方面,如果您不希望ADF等待或不知道Runbook是否失败,则使用Web活动而不是Webhook活动。

如果继续使用ADF Webhook,则需要更改Azure Automation Runbook,使其包括以下参数并进行解析:

param(
    [object] $WebhookData
)

$ErrorActionPreference = "Stop";

try
{
    #parse the webhook parameters
    if (-Not $WebhookData.RequestBody)
    {
        #we're testing in the test pane
        $WebhookData = ConvertFrom-Json -InputObject $WebhookData
    }
    $WebhookBody = ConvertFrom-Json -InputObject $WebhookData.RequestBody
    [string] $callbackUri = $WebhookBody.callbackUri

    #complete your typical runbook work here...

    if ($callbackUri)
    {
        $null = Invoke-WebRequest -Method Post -Uri $callbackUri -ContentType "application/json" -Body '{"StatusCode": "200"}' -UseBasicParsing
    }

}
catch 
{
    if ($callbackUri)
    {
        $null = Invoke-WebRequest -Method Post -Uri $callbackUri -ContentType "application/json" -Body '{"StatusCode": "500","Error": {"ErrorCode":100,"Message","$_"}}' -UseBasicParsing
    }
    "Failed: $_"
    throw $_
}

那应该可以解决ADF认为Runbook永远运行的问题。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...