Azure Functions中的SQL连接池 [英] SQL connection pooling in Azure Functions

查看:135
本文介绍了Azure Functions中的SQL连接池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在传统的Web服务器中,您将具有SQL连接池和与数据库的持久连接.

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

但是我正在考虑将我的整个应用程序创建为Azure Functions. 函数会在每次调用SQL Server时创建一个新连接吗?

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函数当前没有SQL作为输入或输出绑定的选项,因此您需要直接使用SqlClient类进行您的连接并发出您的查询.

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.

只要您遵循处置SQL连接的最佳做法(例如,请参见以下内容: C#SQLConnection池),默认情况下您应该获得池化.

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.

这里是从功能将记录插入SQL的完整示例:

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

这篇关于Azure Functions中的SQL连接池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆