首页 > 解决方案 > 有没有办法响应并继续在 Azure Functions 中使用 NodeJ?

问题描述

因此,在 Azure Functions C# 中,有一个组件将以自定义状态(即202)响应函数的调用者,然后函数继续运行。然而,在 NodeJS 中,要响应您需要使用的调用程序,context.res或者context.done()两者都终止运行,然后任何挂起的 async/await 调用会引发错误,或者该context.res部分被完全跳过。有没有解决的办法?

标签: node.jsazureazure-devopsazure-functions

解决方案


是的,您可以使用持久功能:

在此处输入图像描述

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


推荐阅读