Azure Web Deploy attempts to delete all existing files

Hi

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

Hi,

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

http://docs.octopusdeploy.com/display/OD/Get+the+raw+output+from+a+task

Thanks!

Dalmiro

Both attached.

This time the deploy succeeded… by successfully deleting all files in the root directory first :frowning:

ServerTasks-56.log.txt (95 KB)

Hi,

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

default.html
Scripts
Scripts\Script1.js
Scripts\Script2.js

If you deploy a package with only this content:

scripts\script2.js

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.

Hope that helps!

Dalmiro

Hi Dalmiro

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…

Hi,

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.

You can use this library step to setup your FTP process for this specific set of files https://library.octopusdeploy.com/#!/step-template/actiontemplate-upload-files-by-ftp

Regards,

Dalmiro

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?

Hi

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.

Hope that helps!

Dalmiro

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 installed “Web Deploy 3.5” on the octopus server as suggested on this
thread but it didn’t help :
http://help.octopusdeploy.com/discussions/problems/34064-msdeploy-to-azure-failing

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

  • $destBaseOptions = new-object
    Microsoft.Web.Deployment.DeploymentBaseOptions
    10:55:19
    Verbose

10:55:19
Verbose

  • CategoryInfo : InvalidType: (:slight_smile: [New-Object], PSArgumentExcepti
    10:55:19
    Verbose
    on
    10:55:19
    Verbose
  • FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb
    10:55:19
    Verbose
    jectCommand
    10:55:19
    Verbose
    10:55:19
    Error
    The remote script failed with exit code 1

Hi Dalmiro,

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 installed “Web Deploy 3.5” on the octopus server as suggested on this
thread but it didn’t help :
http://help.octopusdeploy.com/discussions/problems/34064-msdeploy-to-azure-failing

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

  • $destBaseOptions = new-object
    Microsoft.Web.Deployment.DeploymentBaseOptions
    10:55:19
    Verbose

10:55:19
Verbose

  • CategoryInfo : InvalidType: (:slight_smile: [New-Object], PSArgumentExcepti
    10:55:19
    Verbose
    on
    10:55:19
    Verbose
  • FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb
    10:55:19
    Verbose
    jectCommand
    10:55:19
    Verbose
    10:55:19
    Error
    The remote script failed with exit code 1

Hi Dalmiro,

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.

Cheers,

Ross

Hi Ross,

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.

Thanks,

Dalmiro