【问题标题】:Azure functions - How to add my database connection string in app.configAzure 函数 - 如何在 app.config 中添加我的数据库连接字符串
【发布时间】:2021-12-28 17:48:30
【问题描述】:

在 Azure 函数中使用 C# 从 app.config 获取 DB 字符串。

我通过以下方式访问字符串:

var Conn = ConfigurationManager
                   .ConnectionStrings["ConnString"].ConnectionString

寻找使用 conn 字符串控制数据库的好方法。

【问题讨论】:

  • 为什么不放在Function App配置设置中呢?

标签: c# azure-functions


【解决方案1】:

在 Azure 函数中使用 Asp.Net Core 配置系统时,建议使用配置管理器。

您可以通过ConfigurationBuilder 中的GetConnectionString 访问它

var connectionString = config.GetConnectionString("SqlConnectionString");

点击此链接在您的项目中添加配置 - https://blog.jongallant.com/2018/01/azure-function-config/

【讨论】:

猜你喜欢
  • 2013-06-22
  • 2021-12-24
  • 1970-01-01
  • 2019-08-12
  • 1970-01-01
  • 2015-03-30
  • 1970-01-01
  • 1970-01-01
  • 2018-04-30
相关资源
最近更新 更多