【发布时间】:2013-07-31 16:14:55
【问题描述】:
我有一个 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)"/>
【问题讨论】:
-
可能有一些定义的配置转换可能正在执行它。是否有 web.release.config、web.debug.config 等文件。检查这些文件。
-
我有 Web.Release.Config 和 Web.Debug.Config。 Release.Config 配置为将 SQL 字符串更改为实时服务器。就这样。它不应该改变 Blob 存储连接。我会在本地测试转换以确定。
-
分享您的源代码
web.config以及您正在使用的 Web 转换和发布构建配置。在 VS 2012+ - 您可以右键单击转换并选择“预览转换”以查看输出。这就是将推送到 Azure 的内容 - 假设您使用 VS.NET 进行部署。你的部署/打包方法是什么?
标签: azure visual-studio-2012 web-config connection-string azure-storage