对在 Web.config 中为 Azure 部署存储密码的正确程序感到困惑

Confused on what is the correct procedure on storing passwords in Web.config for Azure deployment

我在将 MVC 5 应用程序放到 Azure 上时遇到了非常令人沮丧的经历。我一直在阅读以下页面:http://www.asp.net/identity/overview/features-api/best-practices-for-deploying-passwords-and-other-sensitive-data-to-aspnet-and-azure

但我还没有想好以下内容:

Security Warning: Do not add your secrets .config file to your project or check it into source control. By default, Visual Studio sets the Build Action to Content, which means the file is deployed. For more information see Why don't all of the files in my project folder get deployed? Although you can use any extension for the secrets .config file, it's best to keep it .config, as config files are not served by IIS. Notice also that the AppSettingsSecrets.config file is two directory levels up from the web.config file, so it's completely out of the solution directory. By moving the file out of the solution directory, "git add *" won't add it to your repository.

并且:

Security Warning: Unlike the AppSettingsSecrets.config file, the external connection strings file must be in the same directory as the root web.config file, so you'll have to take precautions to ensure you don't check it into your source repository.

问题如下:当我上传包含外部文件的 Web.config 文件时,我被 "The System cannot find the file specified" 击中了,所以要让它消失,我必须包含 .config文件违背了 Microsoft post 的目的。

我真的真的真的真的不明白。我在 Azure 的门户中添加了 connectionStrings 和 appSetting 的密钥。 将我的密码和秘密放在网上的正确且安全的方法是什么?我错过了什么?是因为我 运行 处于调试模式吗?

据此: How can I secure passwords stored inside web.config?

无需担心访问 Web.config 文件...

但这恰恰违背了微软的 post。

谢谢。

我发现以下技术是最简单的方法。

我没有将这些设置的部署 放入 web.config,而是将测试值保留在那里。然后,我通过 Azure 门户将部署值放入 Azure 网站的“应用程序设置”部分:

当网站运行时,这些设置将优先于 web.config 中的设置。这有助于我避免外部化文件,使我能够保持团队可以共享的合理开发配置,并使部署变得非常容易。

最好的方法是在门户的“连接字符串”部分设置您的机密。在那里设置的任何值都将覆盖您在 web.config 文件中指定的值。

这样一来,它们只会向对网站本身具有管理员访问权限的人公开。拥有对源的完全访问权限甚至不足以获取秘密值。

更多详情here