Azure - Web deployment task failed. An error was encountered when processing operation 'Delete Directory' on (Application Insights)

3

I'm using Right-Click publish in Visual Studio to publish directly to my staging slot in Azure. I've added Application Insights that added a WebJob to my app.

I have enabled Remove additional files at destination and Precompile during Publishing turned on.

But when a Web Job is running and my staging site is not 'stopped', because it's still warmed up - I get the following error:

Web deployment task failed. ((18-Jan-18 22:47:23) An error occurred when the request was processed on the remote computer.)

(18-Jan-18 22:47:23) An error occurred when the request was processed on the remote computer. An error was encountered when processing operation 'Delete Directory' on 'D:\home\site\wwwroot\App_Data\jobs\continuous'. The error code was 0x80070091. The directory is not empty.

at Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode, String maybeFullPath) at Microsoft.Web.Deployment.DirectoryEx.Delete(String path) at Microsoft.Web.Deployment.DirPathProviderBase.Delete(Boolean whatIf) ProjectX.Web 7 0

I can fix this by manually stopping the staging slot, upload it, and then start it again. This is quite cumbersome though.

Is there a fix?

I read somewhere that you can automatically take the (staging) app offline during publish but I can't find the setting.

UPDATE 1

<PropertyGroup>  
<EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>
</PropertyGroup>

...is not working for me.

UPDATE 2

Adding the WEBJOBS_STOPPED setting on the Staging slot is not working for me.

azure
publish
azure-webjobs
publishing
asked on Stack Overflow Jan 18, 2018 by Dirk Boer • edited Jan 21, 2018 by Dirk Boer

2 Answers

5

As you have enabled Application Insights on your Azure App Service, it has internally installed an extension which started a continuous web job and content corresponding to web job got copied to App_Data folder. The actual problem is because extension data get copied to App_Data folder where only user's data should reside instead of infrastructure data.

Now when you are selecting the option "Remove Additional Files From Destination" in visual studio, it tries to remove all contents including Application Insights data from App_Data folder. Since Application Insights web job is already running in background hence corresponding dll files are locked.

Even if you go with option of "App Offline" or "Stop web job" and successfully able to delete all contents then your deployment will succeed but this way your Application Insights will get corrupted and hence you may have to configure Application Insights again.

Suggestion:

Select skip "App_Data" folder along with option "Remove Additional Files From Destination".

It will delete all content except App_Data folder content and hence dll files corresponding to Application Insights continuous web job will be skipped.

Reference : VSTS - Azure App Service Task Documentation

Limitation

Though this solution have a limitation - If you want to remove/modify existing user defined web jobs then can't skip App_Data folder. In such case either have to perform two step deployment or have to reinstall application insight extension again.

answered on Stack Overflow Jan 23, 2018 by Ajay Yadav
0

I found this in another SO question:

<PropertyGroup>
  <EnableMSDeployAppOffline>true</EnableMSDeployAppOffline>
  ...
</PropertyGroup>

... adding to your publishing profile (.pubxml).

The full answer is here: https://stackoverflow.com/a/20888597/647845

UPDATE

This is not working for me. Maybe for others. Seems to ignore the setting.

answered on Stack Overflow Jan 18, 2018 by Dirk Boer • edited Jan 22, 2018 by Dirk Boer

User contributions licensed under CC BY-SA 3.0