Azure Functions + Azure SQL + Node.js 和请求之间的连接池?

Azure Functions + Azure SQL + Node.js and connection pooling between requests?

我想知道 - 有没有办法在 Azure Functions (Node.js) 请求之间建立 Azure SQL 连接池?

创建连接占我的请求总时间的很大一部分 运行,我想知道如何改进它。

乏味网站上的所有示例 http://tediousjs.github.io/tedious/getting-started.html open a new connection, while tedious-connection-pool https://github.com/tediousjs/tedious-connection-pool 我所看到的都是为在单个请求的生命周期内使用单个连接池而设计的,而不是在请求之间。

如有任何建议,我们将不胜感激!

我会选择繁琐的连接池路线 - 它设计用于在请求之间使用。

在您的函数范围之外创建连接池:

// created only on first invocation
let pool = new ConnectionPool(poolConfig, connectionConfig);

module.exports = function(context, trigger) {
   // runs on every invocation, acquiring a connection from the pool
   pool.acquire((err, connection) => {
      ...
   });
}