背景:
我正在将我们的一个 Net Framework 4.5 项目转移到 DevOps 管道中,该管道将部署到我们的应用服务。
为了确保没有任何应用程序 secret 被复制到源代码管理中,我已更新了 Web.config 连接字符串,如下所示:
<connectionStrings configSource="connectionStrings.config"></connectionStrings>
connectionStrings.config 未提交到源代码管理。相反,我们有一个示例版本,在源代码管理中没有有效的字符串,详细信息如下:
<connectionStrings>
<clear/>
<add name="EFDbContext" connectionString="Data Source=XXXXX\SQLEXPRESS;Initial Catalog=XXXXX;Integrated Security=True;Connect Timeout=15;Encrypt=False;TrustServerCertificate=False" providerName="System.Data.SqlClient" />
</connectionStrings>
在 Azure 应用服务中,我们设置了正确的连接字符串。
在管道中,应用程序正在成功构建,但在部署后,应用程序未使用 Azure 应用程序服务中指定的连接字符串,并引发以下错误:
The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
问题:
为什么应用程序忽略应用程序服务环境变量?
我的印象是 Azure 中设置的连接字符串优先。这是正确的吗?
最佳答案
我在您添加为“EFDbContext”的设置中看到了冲突,但在您正在搜索 LocalSqlServer 的代码中。检查您的应用程序设置中是否也有相同的名称
关于c# - 为什么net Framework 4.5 azure部署忽略应用程序服务连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60166126/