I’m trying to set up a deploy using the new Azure Web Deploy in Octopus 3.
I want it to deploy files into a sub-directory on the site and not touch the root directory, but whatever I do the task fails because it tries (and fails) to delete files in the root.
I’ve tried setting up the nuget package so that the target directory is my subdirectory and I’ve also tried setting a “Custom Install Directory” parameter within the deploy task.
Is there any way to prevent it attempting to delete all files within all folders in the target website?
Thanks for getting in touch! Would you mind sharing us a screenshot of your deployment step so we get a glimpse of how you configured it? Make sure all the fields can be seen in it.
Also please send us a deployment log so we can see what is going on during the deployment
Thanks for sharing that information. When you deploy to an Azure WebApp, Octopus compares the content of your NuGet package with the whole content on your Azure WebApp.
Let’s say you have a WebApp deployed in azure with the following contents
default.html
Scripts
Scripts\Script1.js
If you want to add script2.js under the folder Scripts, you’re gonna have to deploy a package with the entire content of the webapp, like this
Octopus will assume that all you want in your webapp, is the content of this package, and will delete the rest of it (in this case the entire root of your app).
tl;dr - Always deploy the full structure of your webapp, and not just pieces of it.
Thanks for your response, that’s a little disappointing.
Could you let me know how to use the “Custom Install Directory” feature?
It has two parameters:
A directory to install to
a Boolean to specify if the target directory should be purged before installation
If a webdeploy always deletes anything from the root directory up that isn’t in the nuget package, then both of these parameters seem somewhat pointless?
Is there any way to achieve the behaviour I’m looking for? I could deploy to a local directory and then use FTP but that seems very clunky…
The “Custom Install Directory” does not work with Azure deployments. Octopus isn’t really designed for this scenario (deploying single files), you will need to do a full deployment.
I have an Azure web app that stores user added content (documents mainly) in a folder under the root of the website. I don’t want that folder to be deleted whenever a new deployment occurs. If publishing from Visual Studio I can tick a box to preserve existing files, but when publishing via the Octopus web app deployment target I don’t seem to have control over that variable and it deletes the folder.
Is there an easy solution to this, such as a MSDeploy ambient variable I can set?
Thanks for reaching out. We’ve added support to this scenario to work in a similar way as deployments from Visual Studio, by adding the following variables:
Octopus.Action.Azure.RemoveAdditionalFiles . Set it to False if you want to keep all the additional files that were already in Azure.
Octopus.Action.Azure.PreserveAppData . Set it to True if you want to keep the contents of App_Data.
Thanks for that. I decided to give this a try, and I upgraded octopus to
version 3.0.17 because I read this variable is only supported in 3.0.12 and
later.
I am now getting an error as shown at the bottom. I have tried both with
and without the Octopus.Action.Azure.RemoveAdditionalFiles variable but it
fails regardless.
I rebooted the octopus server as a random attempt to fix things.
Aside from overwriting the user generated files, this deployment was
working okay on Tuesday when we were running version 3.0.4.
Cheers,
Ross
new-object : Cannot find type
10:55:19
Verbose
[Microsoft.Web.Deployment.DeploymentBaseOptions]: verify that the assembly
10:55:19
Verbose
containing this type is loaded.
10:55:19
Verbose
At C:\Octopus\Work\20150821005516-19\Script.ps1:62 char:20
10:55:19
Verbose
Sorry, but ignore this email. I discovered there was an old step setup in
the process where we were trying to work around this problem using msdeploy
manually. I’ll let you know if I have anything else.
Cheers,
Ross
---------- Forwarded message ----------
From: ross jempson rjempson@gmail.com
Date: 21 August 2015 at 12:32
Subject: Re: Azure Web Deploy attempts to delete all existing files
[Problems #36294]
To: Dalmiro Grañas tender2+db08d86bda@tenderapp.com
Hi Dalmiro,
Thanks for that. I decided to give this a try, and I upgraded octopus to
version 3.0.17 because I read this variable is only supported in 3.0.12 and
later.
I am now getting an error as shown at the bottom. I have tried both with
and without the Octopus.Action.Azure.RemoveAdditionalFiles variable but it
fails regardless.
I rebooted the octopus server as a random attempt to fix things.
Aside from overwriting the user generated files, this deployment was
working okay on Tuesday when we were running version 3.0.4.
Cheers,
Ross
new-object : Cannot find type
10:55:19
Verbose
[Microsoft.Web.Deployment.DeploymentBaseOptions]: verify that the assembly
10:55:19
Verbose
containing this type is loaded.
10:55:19
Verbose
At C:\Octopus\Work\20150821005516-19\Script.ps1:62 char:20
10:55:19
Verbose
Would it be correct that version 3.0.17 defaults to
Octopus.Action.Azure.RemoveAdditionalFiles
to False ?
I recreated our steps and clicked deploy, forgetting that I had removed the
explicit variable I had set, and this time the additional files weren’t
deleted.
Correct, by default the files will not be removed now. In Octopus 3.1 we will have a checkbox on the deploy step for this setting to avoid having to set this variable manually.