Deploying file to Azure web app site folder


I am using the step ‘Deploy an Azure Web App’ but this seems to only allow items to be deployed to the site\wwwroot folder. I need to deploy an applicationHost.xdt file to the site folder but I cannot see a way to do this. I have tried specifying the folder in the step template as …\ (which should be the site folder relative to the wwwroot folder). This did not work. I also tried doing the same in the nuget package but this resulted in a folder within the site\wwwroot\ directory.

Any ideas?



I am using Octopus 3.1.3

Hi Jon,

That’s an interesting question.

When deploying Azure Web Apps we utilize Microsoft’s WebDeploy to sync the files to Azure. I’m sorry, but I don’t know of any way to deploy to a location above the site root.

The only way I can think of to automate deployment of the applicationHost.xdt file is (caveat: I have never tried this) to create a script which uses the KuduExec utility to copy the file to the correct location. This post provides some information on how to use KuduExec. You could package your applicationHost.xdt file and KuduExec into a NuGet package, and configure the script as a PostDeploy script (or simply include the script in the package as PostDeploy.ps1).

If you decide to try that route, please keep me posted on your progress. And if there is any assistance we can provide, please ask. If I get a spare moment I might give it a shot myself.

I hope this helps. I wish I had a more concrete answer for you.



I am having the same problem. Any update/workaround for this?




I believe I may have found a way to achieve this, using the Project Kudo REST API.

If you add your applicationHost.xdt file to your package, you can add a post-deploy script similar to:

$username = '${siteName}'
$password = '{password}'
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

$apiUrl = "https://{siteName}"
$filePath = Join-Path -Path #{OctopusOriginalPackageDirectoryPath} -ChildPath "applicationHost.xdt"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", ("Basic {0}" -f $base64AuthInfo))
$headers.Add("If-Match", "*")

Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method PUT -InFile $filePath -ContentType "multipart/form-data"

The username and password values will need to be deployment-credentials for your site.

If you would like any clarifications on this don’t hesitate to ask. I would love to hear your feedback whether this works for you.