【Azure 应用服务】App Service 在使用GIt本地部署,上传代码的路径为/home/site/repository,而不是站点的根目录/home/site/wwwroot。 这个是因为什么?

本文涉及的产品
日志服务 SLS,月写入数据量 50GB 1个月
简介: 【Azure 应用服务】App Service 在使用GIt本地部署,上传代码的路径为/home/site/repository,而不是站点的根目录/home/site/wwwroot。 这个是因为什么?

问题描述

App Service 在使用GIt本地部署,上传代码的路径为/home/site/repository,而不是站点的根目录/home/site/wwwroot。 这个是因为什么? 并且通过Git发布静态文件的时候不成功。出现“Could not detect any platform in the source directory.” 和 "Error: Couldn't detect a version for the platform 'php' in the repo."错误

 

查看日志

遇见发布时候的错误,除了在发布时候本地可以查看外,还可以在App Service的Kudu中查看。通过下列步骤来查看部署日志:

一:进入Kudu

 

二:进入发布日志(D:\home\site\deployments\temp-xxxx)

 

三:查看日志内容

2021-03-16T03:20:50  Updating branch 'master'.
2021-03-16T03:21:00  Updating submodules.
2021-03-16T03:21:00  Preparing deployment for commit id '208129ed8c'.
2021-03-16T03:21:00  Repository path is /home/site/repository
2021-03-16T03:21:00  Running oryx build...
2021-03-16T03:21:00    Command: oryx build /home/site/repository -o /home/site/wwwroot --platform php --platform-version 7.4 -i /tmp/8d8e82a85ff94d0 --log-file /tmp/build-debug.log 
2021-03-16T03:21:04    Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
2021-03-16T03:21:04    You can report issues at https://github.com/Microsoft/Oryx/issues
2021-03-16T03:21:04    
2021-03-16T03:21:04    Oryx Version: 0.2.20201105.1, Commit: 127d6a3c61a6c0eb67bcfeee0600c3fe71251839, ReleaseTagName: 20201105.1
2021-03-16T03:21:04    
2021-03-16T03:21:04    Build Operation ID: |wb65mFzxGQU=.83c35c89_
2021-03-16T03:21:04    Repository Commit : 208129ed8c6e3b88ee890d958000b1cd72b9bacc
2021-03-16T03:21:04    
2021-03-16T03:21:04    Detecting platforms...
2021-03-16T03:21:05    Could not detect any platform in the source directory.
2021-03-16T03:21:05    Error: Couldn't detect a version for the platform 'php' in the repo.
2021-03-16T03:21:08    Error: Couldn't detect a version for the platform 'php' in the repo.
/opt/Kudu/KuduConsole/Scripts/starter.sh oryx build /home/site/repository -o /home/site/wwwroot --platform php --platform-version 7.4 -i /tmp/8d8e82a85ff94d0 --log-file /tmp/build-debug.log 
2021-03-16T03:21:08

 

问题分析

根据日志总的错误消息,发现有这样两段日志:

 

2021-03-16T03:21:00  Repository path is /home/site/repository
2021-03-16T03:21:00  Running oryx build...
2021-03-16T03:21:00    Command: oryx build /home/site/repository -o /home/site/wwwroot --platform php --platform-version 7.4 -i /tmp/8d8e82a85ff94d0 --log-file /tmp/build-debug.log 

2021-03-16T03:21:05    Could not detect any platform in the source directory.
2021-03-16T03:21:05    Error: Couldn't detect a version for the platform 'php' in the repo.

错误原因是由于执行命令 oryx build /home/site/repository -o /home/site/wwwroot --platform php xxxxxx  时发现build目录中并没有php相关文件导致的。由于使用local git部署需要使用Orxy进行build,如果成功后才会将repository文件夹中的内容输出到wwwroot下,所以最初的问题为什么wwwroot中没有内容。

 

由于目前orxy不支持纯静态文件的部署,在Github中也有相对应的Issue存在:https://github.com/microsoft/Oryx/issues/623

Support for static files? #623


Hi,

I have an existing static site (just .html files) which is currently deployed to netlify.

What configuration do you have to use to just deploy these files? At the moment the build is failing with the error Error: Could not detect the language from repo.

Many thanks!

Howard


@HowardvanRooijen I was able to get a site that was 100% static html, css, and javascript to deploy. It was definitely a workaround style approach but it did work:

  1. remove everything from my repository except
  • git related files (.gitignore)
  • .github directory
  • directory (i called mines 'pregen') containing html, css, js, gifs, etc
  1. in the .github/azure-static-web-apps-*.yml file set the app_location to your html directory (I called mines 'pregen')

This worked for deploying truly static web site with no real build process to Azure Static Web Apps


@kichalla I think the main thing that is confusing here is that Oryx emits an error about detection. As discussed we probably want to have an option to not emit that error and just use the custom status code for saying detection failed. Static Web Apps assumes static content when we see that error code.

 

解决办法

可以在提交时,保证git仓储里面有一个php文件,这样可以保证orxy正常运行build。如增加一个简单的test.php,里面就放入非常简单的一句代码即可:

<?php
phpinfo();
?>

参考资料

从本地 Git 部署到 Azure 应用服务:https://docs.azure.cn/zh-cn/app-service/deploy-local-git

oryx build:https://github.com/Microsoft/Oryx#oryx-build

Support for static files? #623 : https://github.com/microsoft/Oryx/issues/623

相关实践学习
日志服务之使用Nginx模式采集日志
本文介绍如何通过日志服务控制台创建Nginx模式的Logtail配置快速采集Nginx日志并进行多维度分析。
相关文章
|
28天前
|
开发工具 git C++
【App Service】VS Code直接部署App Service时候遇见 “fatal: not a git repository (or any of the parent directories): .git”
通过VS Code发布Python App Service的时候,遇见了发布失败错误: The deployment failed with error: fatal: not a git repository (or any of the parent directories): .git . Please take a few minutes to help us improve the deployment experience
77 24
|
12天前
|
C# Windows
【Azure App Service】在App Service for Windows上验证能占用的内存最大值
根据以上测验,当使用App Service内存没有达到预期的值,且应用异常日志出现OutOfMemory时,就需要检查Platform的设置是否位64bit。
36 11
|
13天前
|
JavaScript C++ 容器
【Azure Bot Service】部署NodeJS ChatBot代码到App Service中无法自动启动
2024-11-12T12:22:40.366223350Z Error: Cannot find module 'dotenv' 2024-11-12T12:40:12.538120729Z Error: Cannot find module 'restify' 2024-11-12T12:48:13.348529900Z Error: Cannot find module 'lodash'
36 11
|
7天前
|
缓存 容器 Perl
【Azure Container App】Container Apps 设置延迟删除 (terminationGracePeriodSeconds) 的解释
terminationGracePeriodSeconds : 这个参数的定义是从pod收到terminated signal到最终shutdown的最大时间,这段时间是给pod中的application 缓冲时间用来处理链接关闭,应用清理缓存的;并不是从idel 到 pod被shutdown之间的时间;且是最大时间,意味着如果application 已经gracefully shutdown,POD可能被提前terminated.
|
11天前
|
开发框架 监控 .NET
【Azure App Service】部署在App Service上的.NET应用内存消耗不能超过2GB的情况分析
x64 dotnet runtime is not installed on the app service by default. Since we had the app service running in x64, it was proxying the request to a 32 bit dotnet process which was throwing an OutOfMemoryException with requests >100MB. It worked on the IaaS servers because we had the x64 runtime install
|
9天前
|
Java 开发工具 Windows
【Azure App Service】在App Service中调用Stroage SDK上传文件时遇见 System.OutOfMemoryException
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
|
10天前
|
安全 Apache 开发工具
【Azure App Service】在App Service上关于OpenSSH的CVE2024-6387漏洞解答
CVE2024-6387 是远程访问漏洞,攻击者通过不安全的OpenSSh版本可以进行远程代码执行。CVE-2024-6387漏洞攻击仅应用于OpenSSH服务器,而App Service Runtime中并未使用OpenSSH,不会被远程方式攻击,所以OpenSSH并不会对应用造成安全风险。同时,如果App Service的系统为Windows,不会受远程漏洞影响!
|
20天前
|
C#
【Azure App Service】使用Microsoft.Office.Interop.Word来操作Word文档,部署到App Service后报错COMException
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).
|
21天前
【Azure App Service】PowerShell脚本批量添加IP地址到Web App允许访问IP列表中
Web App取消公网访问后,只允许特定IP能访问Web App。需要写一下段PowerShell脚本,批量添加IP到Web App的允许访问IP列表里!
|
27天前
|
机器人 Shell Linux
【Azure Bot Service】部署Python ChatBot代码到App Service中
本文介绍了使用Python编写的ChatBot在部署到Azure App Service时遇到的问题及解决方案。主要问题是应用启动失败,错误信息为“Failed to find attribute &#39;app&#39; in &#39;app&#39;”。解决步骤包括:1) 修改`app.py`文件,添加`init_func`函数;2) 配置`config.py`,添加与Azure Bot Service认证相关的配置项;3) 设置App Service的启动命令为`python3 -m aiohttp.web -H 0.0.0.0 -P 8000 app:init_func`。