Transform web.config for Azure Website Deployment for each release environment

前端 未结 2 1811
温柔的废话
温柔的废话 2021-02-10 03:20

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

I can transform the web.config for t

2条回答
  •  梦毁少年i
    2021-02-10 04:14

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

    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.

    {
      "": {
        "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"
            }
        ]
    }
    

    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.

提交回复
热议问题