Eduardo Estrada

Replace Tokens on Continous Delivery Defintion in Microsoft DevOps Description

Replace Tokens on Continuos Delivery Definition in Microsoft DevOps
PowerShell Script to replace the appsettings keys with the environment vars defined on the DevOps Release Definition.
We must to create a PowerShell script.
This Script will find the artifact directory and make a while over all artifacts finding and replacing the appsettings.json vars with the value of the variables defined in the release definition with the same name, and leave with not changes the undefined variables.
The Script extract the files in a new temporal folder take the appsettings.json, replace, delete the file and generate a new file, at the end compress a new file and save it deleting the artifact .zip file.
In case of Windows WebApp in Microsoft DevOps Release or Build Definition Azure Implementing we have and option to replace the appsettings.json for the Dot Net Core WebApps for the variables defined in the stage variables set, in the case of Linux WebApp we don’t have this option.



I created this script in the we can expand a zip to get the appsettings.json replace with the vars of the environment replace the file and zip the entire content crating the new artifact for the azure implementation.