简体   繁体   English

Azure WebJob - 创建目录失败

[英]Azure WebJob - Create Directory fails

I am trying to publish an azure webjob from the VisualStudio, but it fails with error我正在尝试从 VisualStudio 发布一个 azure webjob,但它因错误而失败

An error was encountered when processing operation 'Create Directory' on 'D:\home\site\wwwroot\app_data'.在“D:\home\site\wwwroot\app_data”上处理“创建目录”操作时遇到错误。 The error code was 0x80070002.错误代码是 0x80070002。 Could not find file 'D:\home\site\wwwroot\app_data'.找不到文件“D:\home\site\wwwroot\app_data”。 at Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode, String maybeFullPath) at Microsoft.Web.Deployment.DirectoryEx.CreateDirectory(String path)在 Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode,字符串 maybeFullPath)在 Microsoft.Web.Deployment.DirectoryEx.CreateDirectory(字符串路径)
at Microsoft.Web.Deployment.DirPathProviderBase.CreateDirectory(String fullPath, DeploymentObject source) at Microsoft.Web.Deployment.DirPathProviderBase.Add(DeploymentObject source, Boolean whatIf) Publish failed to deploy.在 Microsoft.Web.Deployment.DirPathProviderBase.CreateDirectory(String fullPath, DeploymentObject source) 在 Microsoft.Web.Deployment.DirPathProviderBase.Add(DeploymentObject source, Boolean whatIf) 发布部署失败。

When I login to this WebApp in portal and open terminal I cannot see the web_app folder.当我在门户中登录此 WebApp 并打开终端时,我看不到 web_app 文件夹。 And when I try to create it using mkdir it fails with当我尝试使用mkdir创建它时,它失败了

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?为什么wwwroot文件夹可能被锁定?

If I try the same thing with a different WebApp - all works fine.如果我用不同的 WebApp 尝试同样的事情 - 一切正常。 I dont want to recreate the webapp我不想重新创建 webapp

UPDATE更新

Application is deployed with WEBSITE_RUN_FROM_ZIP = 1 option.使用 WEBSITE_RUN_FROM_ZIP = 1 选项部署应用程序。 And it is a.NetCore 2.1 web app.它是一个.NetCore 2.1 网络应用程序。

So the next question is:所以下一个问题是:

1) How to add WebJob application to be published into a same package as webapp using dotbet publish command? 1) 如何使用 dotbet publish 命令将要发布的 WebJob 应用程序添加到与 webapp 相同的包中? (similar to https://stackoverflow.com/a/50046561/1300049 ) (类似于https://stackoverflow.com/a/50046561/1300049

2) Or how to deploy the WebJob into alternative location like d:\home\site\jobs\ in VSTS? 2) 或者如何将 WebJob 部署到其他位置,如 VSTS 中的d:\home\site\jobs\

UPDATE 2更新 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:这个基于下面列出的 2 个答案( https://stackoverflow.com/a/40049524/1300049https://stackoverflow.com/a/46661421/1300049 ):

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 1) 在构建阶段使用 MSBuild 构建整个解决方案,并使用类似于此答案中提供的魔法参数 - https://stackoverflow.com/a/46661421/1300049

2) Then, still in a build phase run dotnet publish for the webapp project, but without zipping 2) 然后,仍然在构建阶段为 webapp 项目运行 dotnet publish,但不压缩

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. 3) 作为构建的最终协议,将 webjob 的“app_data”(从第 1 步)复制到 webapp 的发布位置(第 2 步)并将它们全部压缩在一起。

4) In the release phase deploy using the artifacts as usual. 4) 在发布阶段像往常一样使用工件进行部署。 Just make sure that you removed all your previous attempts to solve the problem using "WEBJOBS_ROOT_PATH" environment variable...只要确保您删除了之前使用“WEBJOBS_ROOT_PATH”环境变量解决问题的所有尝试...

What worked for me was going into the Azure portal, deleting the "WEBSITE_RUN_FROM_ZIP" configuration setting, and republishing.对我有用的是进入 Azure 门户,删除“WEBSITE_RUN_FROM_ZIP”配置设置,然后重新发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM