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

标签 azure visual-studio-2012 web-config connection-string azure-storage

我有一个 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/

相关文章:

c# - 为什么将 Visual Studio 作为 "Run as Administrator"运行?

asp.net - 关于machinekey的安全

php - 自动在 Azure 上移动上传的文件

azure - 模板参数 JToken 类型在 Azure 中无效(预期 'String, Uri' 。实际 'Integer' )

使用发布配置文件服务连接执行时 Azure DevOps 发布管道失败

c# - 如何将编码的 Web 性能测试添加到 visual studio 2012 中的负载测试

c++ - 等待 Win32 应用程序中的特定键

asp.net-mvc-3 - Windows Azure - 虚拟应用程序

来自 web.config 的 IIS 虚拟目录

c#-4.0 - Azure 缓存对象的类型转换始终为 null