I am working with DevOps pipeline using yaml and has deployed a .net web application to cloud. I used xml variable substitution to replace a content from configSections in web.config file.
- task: AzureRmWebAppDeployment@4
displayName: 'Service Deploy'
inputs:
appType: webApp
ConnectionType: AzureRM
ConnectedServiceName: '***'
ResourceGroupName: '***'
WebAppName: '***'
enableXmlVariableSubstitution: true
The web.config file contains multiple sections and a common key named "serviceurl" exist in both sections as below.
<configuration>
<configSections>
<section name="roombooking" type="System.Configuration.NameValueSectionHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="cabbooking" type="System.Configuration.NameValueSectionHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<roombooking>
<add key="serviceurl" value="localhost" />
</roombooking>
<cabbooking>
<add key="serviceurl" value="localhost" />
</cabbooking>
</configuration>
The application has deployed to multiple client locations. I have to replace "serviceurl" in web.config during deployment. The "serviceurl" is different for "roombooking" and "cabbooking". I tried xml variable transformation during deployment as mentioned in the document but it replaces both "serviceurl"'s into one value.
The web.config file after deployment as below.
<configuration>
<configSections>
<section name="roombooking" type="System.Configuration.NameValueSectionHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<section name="cabbooking" type="System.Configuration.NameValueSectionHandler, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<roombooking>
<add key="serviceurl" value="http://example.com/" />
</roombooking>
<cabbooking>
<add key="serviceurl" value="http://example.com/"/>
</cabbooking>
</configuration>
I tried with different variable name like "roombooking.serviceurl", "roombooking--serviceurl" etc but nothing applied on individual section key. Is there any other way to apply xml variable substitution to replace "serviceurl" individually. Any help would be appreciated.