【发布时间】:2020-12-30 13:22:12
【问题描述】:
我有一个天蓝色的功能, 在 index.js 我有以下代码
module.exports = function (context, req) {
const createHandler = require('azure-function-express').createHandler;
const app = require('express')();
app.get("/home", (req, res) => {
const y = { "name": "name", "dob": "ddmmyyyy" }
context.res = y
context.done()
});
module.exports = createHandler(app);
context.done();
};
我有function.json:
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"route": "{*segments}"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"disabled": false
}
我的 azure 函数中有上述文件,但如果我到达 api 端点,我将无法获得任何输出,我只是一个空白页。 我必须使用 express 来处理许多其他端点有什么办法可以在 azure 函数中处理。
当我使用 nodejs 本地应用程序设置时,我可以在单个模块中使用 express 和处理许多 api 端点,这在 azure 函数中是否可行?或者我必须为每个端点使用不同的功能
【问题讨论】:
标签: node.js azure azure-functions