Azure Functions NodeJS Express 应用抛出无法确定函数入口点错误
Azure Functions NodeJS Express app throws Unable to determine function entry point error
我正在尝试使用 nodejs 和 express 创建一个简单的 hello world azure 函数应用程序。但是,我收到以下错误:
Exception while executing function: Functions.httpexpressapp. mscorlib: Unable to determine function entry point. If multiple functions are exported, you must indicate the entry point, either by naming it 'run' or 'index', or by naming it explicitly via the 'entryPoint' metadata property.
这是我的代码:
function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"entryPoint": "index",
"disabled": false
}
index.js:
const express = require('express')
const app = express()
app.get('/', (req, res) => res.send('Express JS Hello World App!!!'))
package.json:
{
"name": "httpexpressapp",
"version": "1.0.0",
"description": "sample app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "john doe",
"license": "ISC",
"dependencies": {
"express": "^4.16.3"
}
}
然后,我在函数 app
下有一个 node_modules
目录
感谢任何帮助。提前致谢!
Azure Functions 平台相当自以为是,因为它能够执行绑定和触发器等操作。在 Azure Functions 中用 Node 编码的函数需要采用这种形式。
module.exports = function(context) {
// function logic goes here :)
};
你可以找到一些 JavaScript tips for Azure Functions here. It looks like you are trying to do a simple HTTP-trigger function。看看你的例子,你会想要这样的东西。
module.exports = function(context, req) {
context.res = {
// status defaults to 200 */
body: "Express JS Hello World App!!!"
};
context.done();
};
请注意,Azure Functions 将处理您的 HTTP 请求的路由,因此您可能不想使用 Express.js。
即使您想将 Express 与 Azure 功能一起使用,您也可以这样做 Azure AWS serverless Express
包。很有用。
我正在尝试使用 nodejs 和 express 创建一个简单的 hello world azure 函数应用程序。但是,我收到以下错误:
Exception while executing function: Functions.httpexpressapp. mscorlib: Unable to determine function entry point. If multiple functions are exported, you must indicate the entry point, either by naming it 'run' or 'index', or by naming it explicitly via the 'entryPoint' metadata property.
这是我的代码:
function.json
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"entryPoint": "index",
"disabled": false
}
index.js:
const express = require('express')
const app = express()
app.get('/', (req, res) => res.send('Express JS Hello World App!!!'))
package.json:
{
"name": "httpexpressapp",
"version": "1.0.0",
"description": "sample app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "john doe",
"license": "ISC",
"dependencies": {
"express": "^4.16.3"
}
}
然后,我在函数 app
下有一个node_modules
目录
感谢任何帮助。提前致谢!
Azure Functions 平台相当自以为是,因为它能够执行绑定和触发器等操作。在 Azure Functions 中用 Node 编码的函数需要采用这种形式。
module.exports = function(context) {
// function logic goes here :)
};
你可以找到一些 JavaScript tips for Azure Functions here. It looks like you are trying to do a simple HTTP-trigger function。看看你的例子,你会想要这样的东西。
module.exports = function(context, req) {
context.res = {
// status defaults to 200 */
body: "Express JS Hello World App!!!"
};
context.done();
};
请注意,Azure Functions 将处理您的 HTTP 请求的路由,因此您可能不想使用 Express.js。
即使您想将 Express 与 Azure 功能一起使用,您也可以这样做 Azure AWS serverless Express
包。很有用。