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.