Azure函数中的SQL连接池(SQL connection pooling in Azure Functions)

编程入门 行业动态 更新时间:2024-10-24 12:21:47
Azure函数中的SQL连接池(SQL connection pooling in Azure Functions)

在传统的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

更多推荐

本文发布于:2023-04-28 00:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329660.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   连接池   SQL   Azure   pooling

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!