Azure web deploy and Variable Substitution

We are using the “Deploy an Azure Web App(web deploy)” step to deploy package and update variables to Azure app service. Both .net configuration variables and .net configuration transforms features are enabled and the variables are added with scopes.

After the deployment, we are not seeing the updated values for the app settings in the azure web app.

Does this feature updates only app settings or adds new ones defined in the variables ?

Updating appSettings, applicationSettings, and connectionStrings in: C:\Octopus\Work\20210815042413-59360-665\staging\Web.config

04:24:22 Verbose | Source filePath (C:\Octopus\Work\20210815042413-59360-665\staging\Web.config) does not match destination (webappname\Web.config) differing in attributes (lastWriteTime[‘08/15/2021 04:24:16’,‘08/13/2021 05:52:45’]). Update pending.
04:24:22 Verbose | Updating file (webappname\Web.config).
04:24:22 Verbose | The dependency check ‘DependencyCheckInUse’ found no issues.
04:24:22 Verbose | The synchronization completed in 2 pass(es).
04:24:22 Info | Successfully deployed to Azure. 0 objects added. 1 objects updated. 0 objects deleted.

Hey @pari.shanmugam

Thanks for getting in touch with Octopus!

The .NET XML configurations feature in Octopus will extract your package and parse your *.config files looking for any appSettings, connectionStrings, and applicationSettings elements where the name matches one of your variables.

Therefore to answer your question, that feature doesn’t add new values, it’ll only update existing ones where the name matches one of your Octopus variables.

In my example here, you can see I have some project variables:

And in my web application, I have some appSettings:


After deployment, this shows the application settings in the deployed webapp have been replaced:

If your variable names don’t match the name of an appSetting entry (or connectionString or applicationSettings one too) then the value wont’t be substituted.

I hope that helps, but let me know if you have any further questions!


Thanks for your reply. I have verified the names of the app settings and they appear to be same. In fact, I took the keypair values from azure portal only, but still the values are not getting replaced. e.g MaxCommandRecordCount which has 1000 in azure but has 10000 in octopus which isnt getting replaced after deployment.

We are using Azure webdeploy step and the project variables are added with environment scope only.

Not sure, what I am missing.

Hi @pari.shanmugam,

Are the files to be substituted definitely XML config files, and not newer appsettings.json files? I ask as I don’t see my appSetting values in the Azure portal for the web app I shared earlier:

To find out a bit more, are you able to provide a screenshot (being careful to not share any sensitive information) of the following:

  • A project variable, showing the environment scope.
  • A snippet of the .config file you are trying to substitute values with.
  • The step showing the Azure step where the .NET XML Configuration feature is enabled, ensuring it shows the checkbox of the step being ticked.

I look forward to hearing from you,

Best regards

My expectation is that, it would update the app settings of the azure web app.

Variable with scope:

sample App setting from web config of the project:
add key=“MaxCommandRecordCount” value=“10000”

Process feature config in octopus:

Appsetting from azure portal of the deployment target:

Hi @pari.shanmugam

Thanks for confirming - the reason that the value from Octopus isn’t substituting is that the value added in the portal is overwriting the value stored in the resultant XML file.

I did a test by adding ReleaseNumber to the App settings config in the Azure portal:

Looking at the site after doing so resulted in this output:


I did a quick check of the file, and you can see here its still the old value:

The .NET configuration feature you’re utilizing isn’t able to overwrite the settings you’ve added in the Azure portal.

There are a few options for you though. If you have to use the Deploy an Azure Web App (WebDeploy) step:

  1. Remove the AppSettings from the portal.
  2. If 1) can’t be done, you can run a post-deployment custom script on your step and use the az cli to update the app settings with the values you want. You can loop through a specific set of variables or update them one by one - See az webapp config appsettings | Microsoft Docs or more details.
  3. Take a look at the new Deploy an Azure App Service that was added to Octopus in 2021.1 and use the bulk appSettings update options in the step. See Octopus 2021 Q2: Migrate to the cloud with Octopus Deploy - Octopus Deploy for some more info.

I hope that helps!


Thank you. I am now using the azure cli approach but facing another issue this time. Added a script to add and update all the app settings but the variable values from octopus are not getting populated in the script.


if the variable name doesn’t have any special characters it works, if it has “.” then returns null. Also tried using the $variablewithoutspecialcharacters format, still doesn’t work

Hi @pari.shanmugam,

Thanks for keeping in touch! I attempted to reproduce this behavior, however it succeeded when passing in a variable with a . character. I’m wondering if maybe this might be due to some unexpected syntax issue. My attempt was by doing the following.

Azure script step runs:

$var = $OctopusParameters["var.val"]
az webapp config appsettings set -g <MyResourceGroup> -n <MyWebApp> --settings ReleaseNumber=$var

This resulted in successfully substituting the ReleaseNumber setting with the value of the project variable in Octopus named var.val.

Please let us know if that helps, or if I’ve made any mistakes in my attempt to reproduce this. :slight_smile:

Best regards,


Hi @pari.shanmugam

Further to what my colleague Kenny has mentioned, I created a convention-based way of updating the app settings, helpfully only if they exist in the Azure portal section. See below for the script:

$ResourceGroupName = "YOUR-RESOURCE-GROUP"
foreach($key in $OctopusParameters.Keys) 
    	Write-Host "Checking Octopus variable '$key' exists in webapp: $WebAppName"
        $azWebAppSettingName = (az webapp config appsettings list -g $ResourceGroupName -n $WebAppName --query "[?name=='$key'].name | [0]" -o json)
        if ([string]::IsNullOrWhiteSpace($azWebAppSettingName)) {
        	Write-Warning "AppSetting '$key' doesnt exist in webapp: $WebAppName"
        else {
        	Write-Host "AppSetting '$key' exists in webapp: $WebAppName, updating"
            $rawValue = $OctopusParameters[$key]
        	$response = az webapp config appsettings set -g $ResourceGroupName -n $WebAppName --settings "$key=$rawValue"

The most important thing to note in the above script is that the variables I want to check start with AppConfig. - you can obviously change this to cater to your own requirements. You should also update the values for the resource group, and azure web app name :grinning_face_with_smiling_eyes:

My updated variables look like this:

Note, they also have a “.” in them, I wanted to ensure this case worked for you.

My application web.config also has the matching names:


Therefore if you have specific values that haven’t been added in the portal, the standard Octopus .NET XML Configurations feature can still work for you.

After updating the variable in the Azure portal:

You can see my deployment with release version 2021.08.17.3 has been updated using the custom post-deployment script, but my other 3 variables haven’t:

Lastly, popping back to the Azure portal, you can see the value:

And the value also shows in my test web app:

I hope that helps!

Best regards,

Thanks for the detailed explanation. My requirement is that I need only few variables to be updated or added as part of the deployment and my script is working fine now. Thanks for the super fast replies and support!

Hi @pari.shanmugam

That’s great to hear.

Have a great rest of your week :slight_smile:

Happy Deployments!