【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日志并进行多维度分析。
相关文章
|
1月前
|
JavaScript 前端开发 持续交付
实际工作中 Git Commit 代码提交规范是什么样的?
实际工作中 Git Commit 代码提交规范是什么样的?
80 7
|
29天前
|
网络安全 开发工具 git
Git仓库创建与代码上传指南
本教程介绍了将本地项目推送到远程Git仓库的完整流程,包括初始化本地仓库、添加和提交文件、创建远程仓库、关联远程地址及推送代码。同时,还提供了`.gitignore`配置、分支管理等可选步骤,并针对常见问题(如认证失败、分支不匹配、大文件处理及推送冲突)给出了解决方案。适合初学者快速上手Git版本控制。
|
1月前
|
测试技术 Linux 网络安全
【App Services】App Service报错远程证书无效 - "The remote certificate is invalid according to the validation procedure"
在开发环境中,新部署的应用(App Service)无法与 Salesforce 的远程端点建立 SSL/TLS 连接,报错显示证书无效。经分析,防火墙启用了 SSL Inspection,插入了私有 CA 签发的中间证书,导致 App Service 无法验证。解决方案包括禁用 SSL Inspection、设置 `WEBSITE_LOAD_ROOT_CERTIFICATES` 环境变量或临时禁用代码中的 SSL 验证(仅限测试环境)。
|
15天前
|
开发工具 git 索引
如何使用Git的暂存区来管理代码更改?
如何使用Git的暂存区来管理代码更改?
94 0
|
2月前
|
存储 监控 API
【Azure App Service】分享使用Python Code获取App Service的服务器日志记录管理配置信息
本文介绍了如何通过Python代码获取App Service中“Web服务器日志记录”的配置状态。借助`azure-mgmt-web` SDK,可通过初始化`WebSiteManagementClient`对象、调用`get_configuration`方法来查看`http_logging_enabled`的值,从而判断日志记录是否启用及存储方式(关闭、存储或文件系统)。示例代码详细展示了实现步骤,并附有执行结果与官方文档参考链接,帮助开发者快速定位和解决问题。
114 23
|
4月前
|
应用服务中间件 Linux nginx
【Azure App Service】基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?
基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?Web App Linux 默认使用的 Nginx 版本是由平台预定义的,无法更改这个版本。
175 77
|
3月前
|
网络协议
【Azure App Service】App Service 如何配置私网域名以及证书呢?
本文解答了关于 Azure App Service 如何配置私网域名及证书的问题。App Service 不支持私网域名,自定义域名需配置在公共 DNS 服务器上。文章引用官方文档详细说明了映射自定义 DNS 的步骤,并附带参考资料链接,帮助用户深入了解相关配置方法。
|
3月前
|
存储 安全 开发工具
【Azure Storage Account】利用App Service作为反向代理后续 ---- 隐藏 SAS Token
本文介绍了如何通过App Service作为反向代理,将SAS Token追加到请求URL中,以避免直接在代码或配置文件中存储SAS Token带来的安全性和维护问题。具体步骤包括修改App Service的web.config Rewrite规则,将SAS Token添加到转发的URL中;并在.NET SDK中仅使用不包含SAS Token的Uri进行Blob操作。这样既提高了安全性,也简化了SAS Token的管理。
70 16
|
3月前
|
存储 XML 开发工具
【Azure Storage Account】利用App Service作为反向代理, 并使用.NET Storage Account SDK实现上传/下载操作
本文介绍了如何在Azure上使用App Service作为反向代理,以自定义域名访问Storage Account。主要内容包括: 1. **设置反向代理**:通过配置`applicationhost.xdt`和`web.config`文件,启用IIS代理功能并设置重写规则。 2. **验证访问**:测试原生URL和自定义域名的访问效果,确保两者均可正常访问Storage Account。 3. **.NET SDK连接**:使用共享访问签名(SAS URL)初始化BlobServiceClient对象,实现通过自定义域名访问存储服务。
|
4月前
|
Web App开发 网络协议 网络安全
【Azure App Service】App Service 是否支持HostName SNI 证书?
App Service 支持 HostName SNI 证书。为自定义域名添加 SSL 证书时,可以选择 SNI SSL 和基于 IP 的 SSL。SNI SSL 允许多个 TLS/SSL 证书保护同一 IP 地址上的多个域,适用于大多数现代浏览器。配置方法是在添加自定义域名后,点击 Add binding 配置 SNI SSL。参考文档:[Azure 官方文档](https://docs.azure.cn/zh-cn/app-service/configure-ssl-bindings#add-the-binding)。

热门文章

最新文章