node.js - 有没有办法响应并继续在 Azure Functions 中使用 NodeJ?
问题描述
因此,在 Azure Functions C# 中,有一个组件将以自定义状态(即202
)响应函数的调用者,然后函数继续运行。然而,在 NodeJS 中,要响应您需要使用的调用程序,context.res
或者context.done()
两者都终止运行,然后任何挂起的 async/await 调用会引发错误,或者该context.res
部分被完全跳过。有没有解决的办法?
解决方案
是的,您可以使用持久功能:
module.exports = async function (context, req) {
const client = df.getClient(context);
const instanceId = await client.startNew(req.params.functionName, undefined, req.body);
context.log(`Started orchestration with ID = '${instanceId}'.`);
return client.createCheckStatusResponse(context.bindingData.req, instanceId);
};
在前面的示例中,它将在后台处理 req.params.functionName 并提供一个端点来查询状态。
更多信息:https ://docs.microsoft.com/en-us/azure/azure-functions/durable/quickstart-js-vscode
推荐阅读
- html - 将 R 文件编译成 HTML:data.frame(x,y) 中的错误:找不到 p
- mysql - 如何为每个父母收集最多记录
- javascript - 用 array.map() 中的渲染数据反应 js 问题
- r - R - 按字符迭代地选择和重命名列
- html - 为什么此 html 页面的完整内容未显示
- python - Python timeit.timeit - 排序的片段版本比使用 lambda 运行得更快,为什么?
- go - 使用 JWT 的 GraphQL Golang 身份验证
- javascript - Next.js:react-color - 警告:道具`style`不匹配
- angular - 如何确保用户输入图像(FORM ANGULAR)
- c - 如何在退出 C 中的 Do While 循环后使用在 Do While 循环中输入的值