Web development and the frameworks that go with it have evolved over the years, but when it comes to transforming config file people still use the old ways! If you are still using one of these approaches, you need to change…

  • One configuration file per environment
  • Tokenization of configuration files using parameters.xml and then using a tokenizer to replace values during deployment

VSTS now natively supports config transforms!

Related image

Visual Studio Team Services offers the Azure App Service Deploy task, version 3 of this task now natively supports config transformation. Let’s see this in action… image.png

Scroll down to the File Transforms & Variables Substitution Options section and check the option XML variable substitution image.png

Navigate to the variables section in the release definition and create a key to replace the connection string with a value for a specific environment. image.png

You have the option to encryt the value and also specify the scope of the variable to an environment or the entire definition.

Now fire the release and let this task execute, look at the logs, you’ll see the transformation has been completed for you…

image.png

Let’s look at the value in the config file…

image.png

No more going back to the old ways of transforming webconfig files… VSTS has you covered. #DevOpsOn

Tarun

Related Posts

About Tarun Arora

Tarun Arora is obsessed with high-quality working software, DevOps, Continuous Delivery and Agile. His core strengths are Azure, VSTS, PowerShell, SQL and WPF. He is a Microsoft MVP in Visual Studio Development Tools and the author of 'DevOps & ALM with TFS 2015'.