为每个发布环境转换 Azure 网站部署的 web.config [英] Transform web.config for Azure Website Deployment for each release environment

查看:29
本文介绍了为每个发布环境转换 Azure 网站部署的 web.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio Team Services(以前是 Visual Studio Online)中,我有三个发布环境,每个环境都有一个 Azure 网站部署步骤.

In Visual Studio Team Services (was Visual Studio Online), I have three release environments each with an Azure Website Deploy step.

我可以通过指定选择 Web.Uat.config 的BuildConfiguration"变量(例如 Uat)来转换构建步骤的 web.config.

I can transform the web.config for the build step by specifying the "BuildConfiguration" variable (e.g. Uat) which picks up the Web.Uat.config.

但是,我有多个使用此构建配置的发布环境,它们都需要转换 Web 配置(例如 Dev、Test、Uat、Live).

However I have multiple release environments that use this build configuration which all need to transform the web config (e.g. Dev,Test,Uat,Live).

是否可以在 Azure 网站部署步骤之前指定用于每个发布环境的 Web 配置转换?

Is it possible to specify the the web config transform to use for each release environment before the Azure Website deploy step?

注意:我意识到可以在 Azure 门户网站的所有设置"下指定简单的应用设置和连接字符串,但我需要做的不仅仅是转换这些简单的设置,并且已经为每个环境配置了 web 配置转换在我的解决方案中

Note: I realise that simple appsettings and connectionstrings can be specified in the Azure Portal under "All Settings" for the website but I need to do much more than transform these simple settings and already have configured the web config transforms for each environment within my solution

推荐答案

分词器任务,它是 Release Management Utility Tasks 允许根据环境转换配置文件.

The tokenizer task which comes as a part of Release Management Utility Tasks allows to transform config files depending upon the environment.

可以使用包含所有环境的所有配置的单个 JSON 配置文件,任务将根据环境自动选择正确的配置.

A single JSON config file containing all the configuration for all the environments can be used and the task will automatically pick up the right configuration depending upon the environment.

{
  "<environment>": {
    "CustomVariables": {
    "Variable1": "value1",
    "Variable2": "value2",
  },
    "ConfigChanges": [
        {
          "KeyName": "/configuration/appSettings/add[@key='ServiceURL']",
          "Attribute":"value",
          "Value":"https://ServiceURL"
        },
        {
          "KeyName": "/configuration/appSettings/add[@key='EnableDebugging']",
          "Attribute":"value",
          "Value":"false"
        },
        {
          "KeyName":"/configuration/connectionStrings/add[@name='databaseentities']",
          "Attribute": "connectionString",
          "value": "Integrated Security=True;Persist Security Info=False;Initial Catalog=DB;Data Source=servername"
        }
    ]
}

这样,您可以在单个 JSON 文件中拥有多个环境及其配置,并且标记生成器任务将根据部署进行的环境修改您的配置.

Like this you can have many environments and their configuration in a single JSON file and the tokenizer task will modify your config depending upon the environment on which the deployment is going on.

阅读以上链接的详细信息以了解更多信息.

Read the details on the above link to know more.

这篇关于为每个发布环境转换 Azure 网站部署的 web.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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