且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用每个Azure的部署插槽不同的web.config文件?

更新时间:2022-11-05 11:58:01

您有几种选择。

最明显的就是转换。我不知道为什么你这么快就打折呢?只有少数的设置应环境之间不断变化的,对吧。

The most obvious is the transformations. I don't know why you're so quick to discount it: only a few settings should be changing between environments, right?

或者你可以有多个.config文件,然后让部署脚本的一部分(我希望你不只是使用VS部署)。你的脚本可以选择正确的文件,并将其重命名为web.config中。

Or you can have multiple .config files and then make it part of your deployment script (I hope you're not just using VS to deploy). Your scripts can select the correct file and rename it to web.config.

当然,你可以将所有的应用程序设置和连接字符串的东西,甚至更多,出来的web.config文件,并使用替代配置系统。也许一个巨大的XML或JSON文件,在它的每个环境中的所有设置。或者使用环境变量。

And of course, you can move all the app settings and connection string stuff, and probably more, out of the web.config file and use alternative configuration systems. Perhaps a giant XML or JSON file with all the settings for each environment in it. Or perhaps use environment variables.

真的,就看你写你的部署脚本,并设置您的配置达到你想要的。这不是到微软,这是你的,虽然他们使人们更容易使用多个源的常见配置系统ASP.NET 5。

Really, it's up to you to write your deployment scripts and set your configuration up how you want it. It's not "up to Microsoft", it's up to you, though they have made it even easier to use a common configuration system across multiple sources in ASP.NET 5.