Problems deploying Azure webapp, cannot delete directory, directory was not empty

will.hough's Avatar


05 Oct, 2017 03:01 PM


I am trying to deploy a Nuget package to a web app using the Remove files on the destination that are not part of the deployment set to true. This occasionally fails because Ocotpus attempts to delete a folder that is not empty.

Microsoft.Web.Deployment.DeploymentException: (10/5/2017 2:35:24 PM) An error occurred when the request was processed on the remote computer. ---> Microsoft.Web.Deployment.DeploymentClientServerException: An error was encountered when processing operation 'Delete Directory' on 'D:\home\site\wwwroot\App_Data\jobs'. ---> Microsoft.Web.Deployment.DeploymentException: The error code was 0x80070091. ---> System.IO.IOException: The directory is not empty.

I have stopped the web app prior to this step. This usual works on an retry

Can you help?



  1. Support Staff 1 Posted by Dalmiro Grañas on 05 Oct, 2017 04:14 PM

    Dalmiro Grañas's Avatar

    Hi Will,

    Thanks for reaching out. The path D:\home\site\wwwroot\App_Data\jobs is where the Azure Web Jobs reside. Besides stopping the web app, did you make sure that none of the webjobs were running?


  2. 2 Posted by will.hough on 10 Oct, 2017 11:35 AM

    will.hough's Avatar

    Hi Dalmiro,

    I did and there weren't any running. I have noticed a web job that popups everynow and again. It claims its continous, but then dissappears. I'm not sure if you can stop a web job? I don't see a task for it the step templates. And I wonder if this would even work with a job that pops up



  3. Support Staff 3 Posted by Dalmiro Grañas on 11 Oct, 2017 06:08 PM

    Dalmiro Grañas's Avatar

    Hi Will,

    I brought this questions to the team and a few questions arised:

    You mentioned that in Azure you have webjobs running for that webapp. Do you currently ,in the package you are deploying have, such webjobs under the App_Data folder?

    I'm asking this because the error message claims that the error happened when processing a Delete Directory operation. This operation should only take place if you:

    A) Checked the box Remove additional Files in your deploy step, and in your package under App_Data you do not have a copy of the jobs that are already in Azure. You are basically telling Azure "Deploy all the things from my package and delete the rest"

    B) You do not have the box Preserve App_Data which will of course nuke everything that's on that folder in azure at the time of the deployment, regardless of what's on your package under App_Data

    Its worth mentioning that if you do have the webjobs under App_Data in your package and also in Azure, the deployment will attempt to do a delta on them and not a delete-create. If the problem was happening during this delta operation, the error would be something like Cannot modify file [x] as its in use.

    Best regards,

  4. Support Staff 4 Posted by Dalmiro Grañas on 11 Oct, 2017 06:09 PM

    Dalmiro Grañas's Avatar

    Forgot to add the screenshot that shows the checkboxes I was talking about in my previous reply

  5. 5 Posted by will.hough on 12 Oct, 2017 07:52 AM

    will.hough's Avatar

    Hi Dalmiro,

    I have the setting "Remove files on the destination that are not part of the deployment" checked, so it should delete everything prior to deploying. This in turn would delete the app_data. I hadn't clocked that preserve setting. I will give that a go. I think I've managed to locate the web job that's causing me issues anyway and remove it, thus negating the problem. But if not, I'll give that setting a whirl and report back



Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac