您如何从 Azure Function PowerShell HTTP 触发器立即响应然后响应 "out of band to another Url"?
How do you respond immediately from an Azure Function PowerShell HTTP Trigger and then respond "out of band to another Url"?
我有一个连接到 Slack 命令的 PowerShell HTTP 触发器。如果 PS 触发器在 < 3 秒内响应,则一切正常。我有这个工作
如果需要更长的时间,Slack 需要两件事,立即响应,然后在 response_url
.
上进行带外响应
这行得通。如果我在 set-content
之后放一个 sleep 10
,return 和 Slack 都不会说超时。
有没有办法在 PowerShell 中完成此操作?
@"
{
"response_type": "ephemeral",
"text": "Checking $(get-date) ..."
}
"@ | set-content $res -Encoding Ascii
带外工作。
$b = @"
{
"response_type": "in_channel",
"text": "It's 80 degrees right now.",
"attachments": [
{
"text":"Partly cloudy today and tomorrow"
}
]
}
"@
Invoke-RestMethod $responseUrl -Method post -Body $b -ContentType "application/json"
在 Azure Functions 中执行此操作的正确模式是让您的 HTTP 触发器函数只是将消息推送到队列中,然后 return 立即。然后让另一个 Azure 函数侦听该队列,然后 运行 你的逻辑就在那里。
我有一个连接到 Slack 命令的 PowerShell HTTP 触发器。如果 PS 触发器在 < 3 秒内响应,则一切正常。我有这个工作
如果需要更长的时间,Slack 需要两件事,立即响应,然后在 response_url
.
这行得通。如果我在 set-content
之后放一个 sleep 10
,return 和 Slack 都不会说超时。
有没有办法在 PowerShell 中完成此操作?
@"
{
"response_type": "ephemeral",
"text": "Checking $(get-date) ..."
}
"@ | set-content $res -Encoding Ascii
带外工作。
$b = @"
{
"response_type": "in_channel",
"text": "It's 80 degrees right now.",
"attachments": [
{
"text":"Partly cloudy today and tomorrow"
}
]
}
"@
Invoke-RestMethod $responseUrl -Method post -Body $b -ContentType "application/json"
在 Azure Functions 中执行此操作的正确模式是让您的 HTTP 触发器函数只是将消息推送到队列中,然后 return 立即。然后让另一个 Azure 函数侦听该队列,然后 运行 你的逻辑就在那里。