部署 .Net Core 3.1 Web 应用程序到 Azure Linux Web 服务时出现错误,通过 Azure DevOps 进行部署。

3
我们正尝试将 .Net Core 3.1 Web 应用程序服务部署到 Azure 上,但我们一直遇到无法解决的错误。我们将其部署到一个 App Service 计划(B1)进行测试,似乎对于 .Net Core 3.1,我们只能发布到 Linux 上的 "Code"。我们已经通过 Visual Studio 把它部署了出去,并没有遇到任何问题,但是当通过 Azure Devops 部署时,虽然部署成功,但似乎无法运行。有几个错误:

  1. 无法加载 /usr/local/lib/php/extensions/no-debug-non-zts-20151012/opcache: /usr/local/lib/php/extensions/no-debug-non-zts-20151012/opcache: 无法打开共享对象文件:没有这样的文件或目录

  2. 无法提供目录/home/site/wwwroot/: 找不到匹配的 DirectoryIndex(index.php,index.html,default.htm,default.html,index.htm, index.html,index.php,hostingstart.html),并且由 Options 指令禁止生成服务器目录索引。

    这是我们的错误日志:

2020-02-11T17:08:00.415853887Z   _____                               
2020-02-11T17:08:00.415890488Z   /  _  \ __________ _________   ____  
2020-02-11T17:08:00.415897789Z  /  /_\  \___   /  |  \_  __ \_/ __ \ 
2020-02-11T17:08:00.415902989Z /    |    \/    /|  |  /|  | \/\  ___/ 
2020-02-11T17:08:00.415907889Z \____|__  /_____ \____/ |__|    \___  >
2020-02-11T17:08:00.415913089Z         \/      \/                  \/ 
2020-02-11T17:08:00.415917789Z A P P   S E R V I C E   O N   L I N U X
2020-02-11T17:08:00.415922690Z 
2020-02-11T17:08:00.415927190Z Documentation: http://aka.ms/webapp-linux
2020-02-11T17:08:00.415931590Z PHP quickstart: https://aka.ms/php-qs
2020-02-11T17:08:00.415936090Z PHP version : 7.0.33
2020-02-11T17:08:00.415940490Z Note: Any data outside '/home' is not persisted
2020-02-11T17:08:00.809232004Z Running oryx -appPath /home/site/wwwroot -output /opt/startup/startup.sh     -bindPort 8080 -startupCommand 'dotnet TestProject.dll; apache2-foreground;'
2020-02-11T17:08:01.052506605Z Oryx Version: 0.2.20191105.2, Commit: 67e159d71419415435cb5d10c05a0f0758ee8809, ReleaseTagName: 20191105.2
2020-02-11T17:08:01.054897394Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-02-11T17:08:01.055406213Z Could not find operation ID in manifest. Generating an operation id...
2020-02-11T17:08:01.056002335Z Build Operation ID: dfa49d40-fc36-4418-be4c-4886a385fe91
2020-02-11T17:08:02.861636886Z Writing output script to '/opt/startup/startup.sh'
2020-02-11T17:08:03.264793168Z /opt/startup/startup.sh: 7: /opt/startup/startup.sh: dotnet: not found
2020-02-11T17:08:04.221360854Z AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.16.1.5. Set the 'ServerName' directive globally to suppress this message
2020-02-11T17:08:04.387602773Z AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.16.1.5. Set the 'ServerName' directive globally to suppress this message
2020-02-11T17:08:04.409543294Z Failed loading /usr/local/lib/php/extensions/no-debug-non-zts-20151012/opcache:  /usr/local/lib/php/extensions/no-debug-non-zts-20151012/opcache: cannot open shared object file: No such file or directory
2020-02-11T17:08:04.634700217Z [Tue Feb 11 17:08:04.634541 2020] [mpm_prefork:notice] [pid 28] AH00163: Apache/2.4.25 (Debian) PHP/7.0.33 configured -- resuming normal operations
2020-02-11T17:08:04.635348542Z [Tue Feb 11 17:08:04.634862 2020] [core:notice] [pid 28] AH00094: Command line: 'apache2 -D FOREGROUND'
2020-02-11T17:08:04.646641464Z 172.16.1.1 - - [11/Feb/2020:17:08:04 +0000] "GET /robots933456.txt HTTP/1.1" 404 341 "-" "-"

2020-02-11T17:08:18.196650781Z [Tue Feb 11 17:08:18.171200 2020] [autoindex:error] [pid 41] [client 172.16.1.1:51779] AH01276: Cannot serve directory /home/site/wwwroot/: No matching DirectoryIndex (index.php,index.html,default.htm,default.html,index.htm,index.html,index.php,hostingstart.html) found, and server-generated directory index forbidden by Options directive
2020-02-11T17:08:18.197972531Z 172.16.1.1 - - [11/Feb/2020:17:08:18 +0000] "GET / HTTP/1.1" 403 363 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"

我们尝试了很多不同的发布配置,但是似乎没有办法通过这一步。这是我们的CI YAML: CI YAML 以下是我们的发布流程配置: Release Pipeline 非常感谢任何指导或提示。我们没有找到太多关于这个特定错误的文档或如何解决它的方法。
1个回答

7
尽管我选择了App Service Plan作为.NET Core 3.1应用程序,但App Service本身似乎没有设置。为了修复这个问题,您需要进入App Service的配置选项卡,进入“常规设置”,并确保设置以下设置:

.Net Core Stack

请注意,只有在选择 .Net Core Stack 后,主版本和次版本才会出现。我希望这是一些更明显的东西,并且如果您将其设置为运行时堆栈创建应用程序服务计划,则自动设置。我希望这可以帮助任何遇到此问题的人。
更新:
当我们推出新版本时,我们意识到 AzureDevops 正在覆盖此 Stack 设置。如果用户正在创建发布管道,但他们没有适当的 Azure 访问权限,则发布中的 Azure 应用程序服务部署任务中的“运行时堆栈”将不会填充。拥有提升特权的人将看到所有可用的不同选项。当前可选择的选项是“Latest (DOTNETCORE|Latest)”。目前“3.1 (DOTNETCORE|3.1)”不是可用选项。

我目前面临你在更新中描述的问题。Azure Devops部署管道正在覆盖应用程序服务配置,devops没有选择dotnet core 3.1的选项。选择“3.0”是可行的,但只有当我的应用程序针对3.0进行编译时才有效。 “LTS”和“latest”选项只会使用空白覆盖运行时堆栈的应用设置(手动输入“3.1”,“3.1.0”,“3.1.x”等都具有相同的效果)。 - Brian
1
您可以在此处跟随缺失的 DOTNETCORE|3.1 在 Azure DevOps 中的问题: https://github.com/microsoft/azure-pipelines-tasks/issues/12178 - Dave Skender
遇到了相同的问题,这帮助我诊断了问题。谢谢。 - ossentoo

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接