We use Replace tokens
task that's available in VSTS
You can also specify prefix and suffix for string replacement.
Then in your ServiceConfiguration.Cloud.cscfg
, you would use the defined prefix and suffix to indicate what string to be replaced. The value of will be taken from Variables
that you defined in VSTS. You will then put the name of the variable for this setting in between the prefix and suffix.
Example of ServiceConfiguration.Cloud.cscfg
file that will be replaced by Password
variable.
<Setting name="SqlPassword" value="#{Password}#" />
This can be used to convert / replace any string in any configuration file. One thing to note is that in some configuration files, the schema will validate the value of specific setting.
Such as case with ServiceConfiguration
's Certificate
setting in Cloud Service. The value must be valid certificate thumbprint (that is any digit 0-9 and/or letter A-F, lower and uppercase). The service configuration schema defined this and build will fail if the value doesn't meet the schema requirement.
To get around this, we have another task in our Release to replace certificate. The prefix / suffix for this could be something like abc
and def
, respectively. The name of the variable will be 001
. Unfortunately, it's not as descriptive because it has to be valid certificate thumbprint.
<Certificate name="MainSSL" thumbprint="abc001def" thumbprintAlgorithm="sha1" />