SQL connection pooling in Azure Functions

2019-07-28 06:34发布

问题:

In traditional webservers you would have a SQL connection pool and persistent connection to the database.

But I am thinking of creating my entire application as Azure Functions. Will the functions create a new connection the SQL server everytime its called upon?

回答1:

Azure Functions doesn't currently have SQL as an option for an input or output binding, so you'd need to use the SqlClient classes directly to make your connections and issue your queries.

As long as you follow best practices of disposing your SQL connections (see this for example: C# SQLConnection pooling), you should get pooling by default.

Here's a full example of inserting records into SQL from a function: https://www.codeproject.com/articles/1110663/azure-functions-tutorial-sql-database