Delete Azure Config Transforms

Hi,

We are using web.config transforms during deployment of a Azure Web App. The transforms are being applied correctly but I am having difficulty removing the transforms from the web app after deployment. I have used an extension of powershell script found here in a post deployment script step as can be seen in the “Post Deployment Script.png” attachment.

After deployment I see the following excepts in the deployment log:

11:33:25   Info     |       Transforming 'C:\Octopus\Work\20171010113210-2742\staging\Web.config' using 'C:\Octopus\Work\20171010113210-2742\staging\Web.Debug.config'.

...

11:34:18   Verbose  |       Executing 'C:\Octopus\Work\20171010113210-2742\staging\Octopus.Action.CustomScripts.PostDeploy.ps1'
11:34:19   Verbose  |       Name                           Value
11:34:19   Verbose  |       ----                           -----
11:34:19   Verbose  |       PSVersion                      5.1.15063.296
11:34:19   Verbose  |       PSEdition                      Desktop
11:34:19   Verbose  |       PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
11:34:19   Verbose  |       BuildVersion                   10.0.15063.296
11:34:19   Verbose  |       CLRVersion                     4.0.30319.42000
11:34:19   Verbose  |       WSManStackVersion              3.0
11:34:19   Verbose  |       PSRemotingProtocolVersion      2.3
11:34:19   Verbose  |       SerializationVersion           1.1.0.1
11:34:19   Verbose  |       PowerShell Environment Information:
11:34:19   Verbose  |       OperatingSystem: Microsoft Windows NT 10.0.15063.0
11:34:19   Verbose  |       OsBitVersion: x64
11:34:19   Verbose  |       Is64BitProcess: True
11:34:19   Verbose  |       CurrentUser: NT AUTHORITY\SYSTEM
11:34:19   Verbose  |       MachineName: BUILDSERVER
11:34:19   Verbose  |       ProcessorCount: 1
11:34:19   Verbose  |       CurrentDirectory: C:\Octopus\Work\20171010113210-2742\staging
11:34:19   Verbose  |       CurrentLocation: C:\Octopus\Work\20171010113210-2742\staging
11:34:19   Verbose  |       TempDirectory: C:\Windows\TEMP\
11:34:19   Verbose  |       HostProcessName: powershell
11:34:19   Verbose  |       Adding bundled Azure PowerShell modules to PSModulePath
11:34:19   Verbose  |       Authenticating with Service Principal
11:34:19   Verbose  |       WARNING: Parameter 'Environment' is obsolete. This parameter is only for
11:34:19   Verbose  |       backwards compatibility; users should use EnvironmentName instead.
11:34:20   Verbose  |       Environment           : AzureCloud
11:34:20   Verbose  |       Account               : ********-****-****-****-************
11:34:20   Verbose  |       TenantId              : ********-****-****-****-************
11:34:20   Verbose  |       SubscriptionId        : ********-****-****-****-************
11:34:20   Verbose  |       SubscriptionName      : ********
11:34:20   Verbose  |       CurrentStorageAccount :
11:34:20   Verbose  |       Invoking target script "C:\Octopus\Work\20171010113210-2742\staging\Octopus.Action.CustomScripts.PostDeploy.ps1" with  parameters
11:34:20   Info     |       Removing transform file 'C:\Octopus\Work\20171010113210-2742\staging\Web.Debug.config'
11:34:20   Info     |       Removing transform file 'C:\Octopus\Work\20171010113210-2742\staging\Web.Live.config'
11:34:20   Info     |       Removing transform file 'C:\Octopus\Work\20171010113210-2742\staging\Web.Staging.config'

Which shows that the transform is being applied correctly and then (after deployment) being removed. Yet, when I subsequently check on Azure, the config transforms are still present.

Now, my guess is that I’m removing the config transforms from the staging directory and not from Azure so, if correct, my question is how do I remove these files after the transform has been performed but prior to publishing to Azure. Of course, if this guess is incorrect, I’m keen to understand why the transforms are being published at all.

Thanks in advance for any help.

Ian

Post_Deployment_Script.png

Hi,

Thanks for reaching out! The Post Deployment Script runs after the deployment to azure was already done. You need to include that script in the Deployment Script box for it to happen right before the files are pushed to Azure.

Keep in mind that since you already have a copy of these extra config files in Azure, the next time you deploy your package contents without these files, unless you check the box “Remove Additional Files”, you’ll still see the old copies in the cloud.

You need to check that box to tell Azure “Deploy only the files I’m pushing, and delete any other file that’s not on that list regardless if its already in the cloud”

Hope that helps,
Dalmiro