且构网

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

为每个发布环境转换 Azure 网站部署的 web.config

更新时间:2022-11-05 12:12:19

分词器任务,它是 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.