0

I have an Azure DevOps pipeline that besides other things installs a Windows service. The service uses a config file that contains a connection string and some license key:

   <connectionStrings>
    <add name="myConnection" connectionString="Data Source=localhost;Initial Catalog=mydb;UID=username;Password='passwordtobereplaced';Connect Timeout=15;MultipleActiveResultSets=true;"/>
  </connectionStrings>

  <appSettings>
    <add key="SomeApiKey" value="tobereplaced"/>
  </appSettings>

The values of the connection string and of the license key need to be replaced in the pipeline. The pipeline has variables myConnection and SomeApiKey with the appropriate values that have to replace placeholders in the config file. I added a File Transform task that should perform the replacement. But to my surprise, only myConnection is replaced, but SomeApiKey is not. What can be the cause?

BTW, the pipeline also deploys a web application that also uses the same settings in Web.config. The IIS web app deploy task has XML Variable Substitution checkbox checked. And in this web.config BOTH variables are replaced correctly.

David Shochet
  • 5,035
  • 11
  • 57
  • 105

2 Answers2

0

In your current situation, we recommend you can try to use the Azure App Service Settings task to try to update your app settings.

In your statements, we are not sure what task you are using. And if you are using the Azure App Service deploy task, we can use the File Transforms & Variable Substitution Options to help us link the web.config file.

Felix
  • 1,104
  • 3
  • 6
  • Thank you for your answer. I will try Azure App Service Settings. I use Windows Service Manager task. It has no File Transforms & Variable Substitution Options. Azure App Service deploy does not seem to work with Windows Services. Don't you have any explanation why one setting is replaced, and another is not? – David Shochet Apr 26 '21 at 12:17
  • Azure App Service Settings is used for Web apps, not for Windows services. – David Shochet Apr 26 '21 at 12:40
0

I found Replace Tokens task that works correctly. Though it is still not clear what was wrong with File Transform task.

David Shochet
  • 5,035
  • 11
  • 57
  • 105