gpt4 book ai didi

.net - 在 Azure 应用程序设置中配置我的连接字符串,并将其在我的 web.config 中配置为环境变量

转载 作者:行者123 更新时间:2023-12-02 23:01:29 26 4
gpt4 key购买 nike

我在 Azure 中有一个 Web 应用程序,并且在其应用程序设置中配置了 connectionStrgin,但我不知道如何将此配置设置为应用程序 web.config (.Net) 中的环境变量。

有人有一些文档或者知道如何实现这一点,到目前为止我已经查看了微软和其他网站的文档进行故障排除,但我还没有找到解决方案

最佳答案

连接字符串

对于 ASP.NET 等 .NET 应用程序,这些连接字符串会在运行时注入(inject)到 .NET 配置 connectionStrings 设置中,覆盖键等于链接数据库名称的现有条目。

这些设置也将在运行时作为环境变量提供,并以连接类型为前缀。环境变量前缀如下:

SQL Server:SQLCONNSTR_
MySQL:MYSQLCONNSTR_
SQL 数据库:SQLAZURECONNSTR_
定制:CUSTOMCONNSTR_

您可以使用 ConfigurationManager.ConnectionStrings["keyname"]; 检索应用程序中的设置。

then in my web.config I should have the connectionString blank and will automatically use the connectionString of the application settings?

是的,确实如此。当您在 azure 应用程序设置和 web.config 中都有连接字符串时,the azure settings will override web.config 。当您在本地测试时,您可以在 web.config 中设置键/值。

关于.net - 在 Azure 应用程序设置中配置我的连接字符串,并将其在我的 web.config 中配置为环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53936382/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com