【发布时间】:2020-08-12 12:51:36
【问题描述】:
我有一个带有 Web Hook Activity 的 Azure 数据工厂 V2,用于调用带有 HTTP 触发器的 Azure 函数,代码如下。
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Interact with query parameters or the body of the request.
$callBackUri = $Request.Body.callBackUri
Write-Output "CallBack url is : $callBackUri"
# Need to return Http 202 Accepted here
# This is the issue, it does not actually return from this point at the moment
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::Accepted
Body = $body
}) -Clobber
# some long running processing
$seconds = 60
Write-Output "Returned http 202. Sleeping for $seconds seconds.."
Start-Sleep -Second $seconds
Write-Output "Sleep complete."
# Invoke the callback
Invoke-WebRequest -Uri $callBackUri -Method POST -ContentType 'application/json' -Body "This is a callback"
该函数应该接收到 HTTP 请求,立即返回一个 HTTP 202 Accepted 响应,然后继续处理。该过程完成后,该函数需要在 callBackUri 上调用 POST 以向 Web Hook Activity 指示处理已完成。
但是,该函数不返回 202,而是完成了长时间运行的过程,然后返回 203。我知道最初设置了输出绑定,并且仅在执行整个脚本后才返回。
有没有办法解决这个问题?我只是想实现这个:https://mrpaulandrew.com/2019/06/18/azure-data-factory-web-hook-vs-web-activity/
【问题讨论】:
标签: azure-data-factory-2 azure-function-app powershell-core