如何使用microsoft.practices.enterpriselibrary.data中的Azure App Service中的连接字符串使用

发布于 2025-01-31 18:33:22 字数 292 浏览 3 评论 0原文

我们的应用程序使用microsoft.practices.enterpriselibrary.data,并且连接字符串在app.config中。 我们将其迁移到Azure应用程序服务,并创建2个环境,开发和产品。 Dev具有Dev Database Connection字符串和Azure App Service配置中的配置 POD在Azure App Service配置中具有产品数据库连接字符串和配置,

我想问我们如何在C#代码中实现使用Azure App Service中的连接字符串,而不是使用App.Config。

非常感谢您的支持

Our application use Microsoft.Practices.EnterpriseLibrary.Data, and the connection string is in app.config.
We migrate this to an Azure App Service and create 2 environment, Dev and Prod.
Dev has Dev database connection string and configure in Azure App Service configuration
Prod has Prod database connection string and configure in Azure App Service configuration

I would like to ask how can we implement in the C# code use the connection string in Azure App Service, instead of use app.config

Thank you very much for your support

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的呼吸 2025-02-07 18:33:22

Azure App Services的应用程序设置专门为完成您的要求而构建。

您可以使用应用程序设置来覆盖AppSettings.json文件中的“设置”。这些设置可以专门为插槽设置。

您还可以使用专门用于完成您想要的事情的连接字符串。只需在appsettings.json文件中创建连接字符串设置,按名称(例如sqlliveconnection)在解决方案中创建“连接”文件,然后将测试连接字符串或没有连接字符串放置。部署后,您的应用服务设置将覆盖该设置的值。

Azure App Services have Application settings specifically built to do what you are asking about.

enter image description here

You can use application settings to overwrite your "Settings" inside your appsettings.json file. Those settings can be set specifically for a slot.

You can also use connection strings which are specifically meant to do what you want. Simply create the connection string setting in your appsettings.json file in solution by name (e.g. sqlLiveConnection) and put your testing connection string or no connection string there. Your app service setting will overwrite that setting's value once deployed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文