如何使用每个Azure的部署插槽不同的web.config文件? [英] How can I use a different web.config file for each Azure deployment slot?

查看:844
本文介绍了如何使用每个Azure的部署插槽不同的web.config文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个Azure的部署插槽:开发,分期,生产等

I have several Azure deployment slots: dev, staging, production, etc.

我要创建一组web.config文件中,每一个部署插槽。因此,网络dev.config,网络staging.config等。

I want to create a set of web.config files, one for each deployment slot. So web-dev.config, web-staging.config, etc.

我不希望因为如果你有超过一个或两个设置似乎容易很多,只是有一个文本文件中的所有设置使用天青插槽特定的设置。

I do not want to use the slot-specific settings in Azure because if you have more than one or two settings it seems vastly easier to just have all your settings in a text file.

我不想写在一个单一的web.config文件的XML转换,因为这是疯了。配置文件已经有了足够的复杂性没有额外的间接层。即使我没有想到的是,web.config中变换似乎被捆绑到构建配置,而不​​是部署目的地。我不希望我的扭曲的构建过程对我的部署流程的好处。

I do not want to write XML transforms on a single web.config file because that is insane. Config files already have enough complexity without an extra layer of indirection. And even if I didn't think that, web.config transforms seem to be tied to build configuration and not to a deployment destination. I don't want to contort my build process for the benefit of my deploy process.

我知道,复制和粘贴配置设置跨文件是毛,但我们在这里。直到有人在MS在ASP.net修复配置,我只是想有一个文件每个部署目的地和收工。

I know copying and pasting config settings across files is gross but here we are. Until someone at MS fixes configuration in ASP.net, I just want to have one file for each deployment destination and call it a day.

我该怎么办呢?

推荐答案

您有几种选择。

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

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.

这篇关于如何使用每个Azure的部署插槽不同的web.config文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆