gpt4 book ai didi

azure - 将 Web.Config 发布到 Azure 会删除 Azure 存储连接字符串

转载 作者:行者123 更新时间:2023-12-03 01:56:09 27 4
gpt4 key购买 nike

我有一个 web.config,其中包含我的 SQL 连接字符串和 Azure Blob 存储连接字符串。

Web.Config 转换将我的本地 SQL 连接字符串替换为 Azure 连接字符串。

当我将站点发布到 Azure 时,Blob 存储连接字符串将被删除并替换为重复的 SQL 连接字符串,但替换为 Blob 存储字符串的名称。

我发现的唯一修复方法是通过 FTP 登录,然后从本地计算机手动将错误的存储连接字符串更改为正确的字符串。

如何让 VS 将我的 Web 配置发布到 Azure 并保留它!!!

Web.Config

      <connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=https;AccountName=;AccountKey=" />
</connectionStrings>

Web.Release.Config

  <connectionStrings>
<add name="DefaultConnection"
connectionString="Server=.database.windows.net,1433;Database=;User ID=@;Password=!;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;"
providerName="System.Data.SqlClient"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>

最佳答案

我也遇到了和你类似的问题。我不确定为什么,但是当您在 Azure 门户的“配置选项卡”中定义连接字符串并在链接资源选项卡上关联“链接资源”时,它可能会覆盖 Web.config 转换中的某些属性,从而导致意外结果。设置新的 Azure 网站时的选项之一是链接到(或创建新的)数据库以与您的网站关联 - 从而自动分配相关的连接字符串,该字符串可能会尝试覆盖 Web.Release 中定义的转换操作。配置。

检查并查看删除“Azure 门户”内的所有连接字符串和链接资源是否可以解决您的问题。只需确保在 Web.Release.config 中正确定义了生产数据库和存储连接字符串。

关于azure - 将 Web.Config 发布到 Azure 会删除 Azure 存储连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17965272/

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