1

I wonder - is there a way to have an Azure SQL connection pool between Azure Functions (Node.js) requests?

Creating a connection is a significant chunk of the total time my requests are running and I wonder how to improve it.

All the examples on the tedious website http://tediousjs.github.io/tedious/getting-started.html open a new connection, while tedious-connection-pool https://github.com/tediousjs/tedious-connection-pool from what I can see is designed for using a single connection pool for a lifetime of a single request, not between requests.

Any suggestions are appreciated!

1 Answer 1

3

I'd go the tedious-connection-pool route - it's designed to be used between requests.

Create the connection pool outside of your function scope:

// 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) => {
      ...
   });
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.