在传统的Web服务器中,您将拥有SQL连接池和与数据库的持久连接。
但我正在考虑将我的整个应用程序创建为Azure Functions。 这些函数是否会在SQL服务器每次调用时创建一个新连接?
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?
最满意答案
Azure Functions当前没有SQL作为输入或输出绑定的选项,因此您需要直接使用SqlClient类来建立连接并发出查询。
只要您遵循处理SQL连接的最佳实践(请参阅此示例: C#SQLConnection池 ),您应该默认使用池。
以下是从函数中将记录插入SQL的完整示例: https : //www.codeproject.com/articles/1110663/azure-functions-tutorial-sql-database
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
更多推荐
发布评论