【发布时间】:2019-04-15 09:35:49
【问题描述】:
我正在尝试将 Azure 函数连接到我也在 Azure 中创建的 SQL 数据库。听起来很简单,微软甚至有一个很好的 POC 教程。但是,就我而言,Azure 函数正在丢弃我无法解决的“入口点”错误。
我查看了其他一些关于 stackoverflow 的讨论 (Can't connect Node.js server to Azure SQL Database),然后用谷歌搜索了它。不幸的是,这似乎都没有帮助。我更新了“function.json”来设置我的入口点,如下所示。
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"access": "listen",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"entryPoint": "index",
"direction": "out",
"name": "res"
}
]
}
我的 index.js 代码是一个非常简单的尝试连接到数据库并告诉我成功。
var Connection = require('tedious').Connection;
var config = {
userName: 'XXXX',
password: 'XXXX!',
server: 'XXXX.database.windows.net',
// If you are on Microsoft Azure, you need this:
options: {encrypt: true, database: 'XXXXX'}
};
var connection = new Connection(config);
connection.on('connect', function(err) {
// If no error, then good to proceed.
console.log("Connected");
});
通常这应该连接到数据库并将“已连接”打印到控制台,但不知何故它会显示此错误:
[Error] Executed 'Functions.TediousTest' (Failed, Id=XXXXXXX)
node exited with code 1
[error] Worker was unable to load function TediousTest: '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.',[error] Worker XXXXXX uncaught exception: ReferenceError: executeStatement is not defined
希望这是足够的信息来理解我的问题。数据库目前没有专门的防火墙等。此外,似乎代码 sn-p 甚至无法与防火墙取得联系。提前致谢。
【问题讨论】:
标签: javascript node.js azure api azure-functions