如何解决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永远运行的问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。