4

I am trying to publish an azure webjob from the VisualStudio, but it fails with error

An error was encountered when processing operation 'Create Directory' on 'D:\home\site\wwwroot\app_data'. The error code was 0x80070002. Could not find file 'D:\home\site\wwwroot\app_data'. at Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode, String maybeFullPath) at Microsoft.Web.Deployment.DirectoryEx.CreateDirectory(String path)
at Microsoft.Web.Deployment.DirPathProviderBase.CreateDirectory(String fullPath, DeploymentObject source) at Microsoft.Web.Deployment.DirPathProviderBase.Add(DeploymentObject source, Boolean whatIf) Publish failed to deploy.

When I login to this WebApp in portal and open terminal I cannot see the web_app folder. And when I try to create it using mkdir it fails with

The system cannot find the file specified.

I tested it a bit more - and I cannot create any folders there!

Why the wwwroot folder might be locked?

If I try the same thing with a different WebApp - all works fine. I dont want to recreate the webapp

UPDATE

Application is deployed with WEBSITE_RUN_FROM_ZIP = 1 option. And it is a .NetCore 2.1 web app.

So the next question is:

1) How to add WebJob application to be published into a same package as webapp using dotbet publish command? (similar to https://stackoverflow.com/a/50046561/1300049)

2) Or how to deploy the WebJob into alternative location like d:\home\site\jobs\ in VSTS?

UPDATE 2

Found a workaround that I dont really like. But it works. But I am more than open for a better solutions.

This one is based on 2 answers (https://stackoverflow.com/a/40049524/1300049 and https://stackoverflow.com/a/46661421/1300049) listed below:

1) During the build phase build the whole solution using MSBuild with magic arguments similar to the ones provided in this answer - https://stackoverflow.com/a/46661421/1300049

2) Then, still in a build phase run dotnet publish for the webapp project, but without zipping

3) As a final accord of a build copy the "app_data" of the webjob (from step 1) into the publish location of the webapp (step 2) and zip it all together.

4) In the release phase deploy using the artifacts as usual. Just make sure that you removed all your previous attempts to solve the problem using "WEBJOBS_ROOT_PATH" environment variable...

JleruOHeP
  • 10,106
  • 3
  • 45
  • 71
  • 1
    Are you by a chance [running from a zip package](https://github.com/Azure/app-service-announcements/issues/84)? – David Ebbo Aug 28 '18 at 04:40
  • @DavidEbbo, yep for the webapp we have WEBSITE_RUN_FROM_ZIP = 1 – JleruOHeP Aug 28 '18 at 04:56
  • 1
    Normally, when using VS, web app and Webjobs should all be deployed together in a single package, and not as separate gestures. – David Ebbo Aug 28 '18 at 04:58
  • @DavidEbbo right, thanks for pointing to this. By any chance do you know how can I deploy webjob to d:\home\site\jobs\ in VSTS? – JleruOHeP Aug 28 '18 at 05:12
  • @DavidEbbo found one of your answers: https://stackoverflow.com/a/50046561/1300049. Is it possible to repeat those steps somehow for a .NetCore 2.1 webapp configured as console application in Visual Studio? – JleruOHeP Aug 28 '18 at 05:22
  • Unfortunately, there is currently no msbuild support for deploying WebJobs with a **Core** Web App. Your 'Update 2' solution makes sense, but admittedly it's non-trivial to get right. An alternative is to publish the WebJobs separately using the WebJobs API, which will end up placing them in the alternate `d:\home\site\jobs\` location (because it detects you're running from zip package). But still, I think it's cleaner to have everything in one zip package. – David Ebbo Aug 28 '18 at 17:53

1 Answers1

4

What worked for me was going into the Azure portal, deleting the "WEBSITE_RUN_FROM_ZIP" configuration setting, and republishing.

Code Slinger
  • 1,100
  • 1
  • 11
  • 16
  • Thanks for the suggestion! You can also change the deployment method from the devops pipeline if you want, but my goal was to keep running from zip - much better deployment performance and a warm feeling of a nice isolation:) – JleruOHeP Oct 28 '19 at 22:21
  • Similarly I had to delete "WEBSITE_RUN_FROM_PACKAGE" config – Miłosz Wierzbicki Apr 21 '21 at 09:17