【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日志并进行多维度分析。
相关文章
|
5天前
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub的解决之法
An exception occurred while retrieving properties for Event Hub: logicapp. Error Message: 'ClientSecretCredential authentication failed: AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found. Check to make sure you have the correct tenant ID and are signing into the correct cloud. Che
|
11天前
|
安全
【Azure App Service】App service无法使用的情况分析
App Service集成子网后,如果子网网段中的剩余IP地址非常少的情况下,会在App Service实例升级时( 先加入新实例,然后在移除老实例 )。新加入的实例不能被分配到正确的内网IP地址,无法成功的访问内网资源。 解决方法就是为App Service增加子网地址, 最少需要/26 子网网段地址。
|
20天前
|
C++
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub
【Azure Logic App】使用Event Hub 连接器配置 Active Directory OAuth 认证无法成功连接到中国区Event Hub
|
20天前
【Azure Logic App】在逻辑应用中开启或关闭一个工作流是否会对其它工作流产生影响呢?
【Azure Logic App】在逻辑应用中开启或关闭一个工作流是否会对其它工作流产生影响呢?
|
20天前
|
存储 SQL JSON
【Azure Logic App】微软云逻辑应用连接到数据库,执行存储过程并转换执行结果为JSON数据
【Azure Logic App】微软云逻辑应用连接到数据库,执行存储过程并转换执行结果为JSON数据
【Azure Logic App】微软云逻辑应用连接到数据库,执行存储过程并转换执行结果为JSON数据
|
20天前
|
安全 网络安全 Windows
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
【Azure App Service】遇见az命令访问HTTPS App Service 时遇见SSL证书问题,暂时跳过证书检查的办法
|
20天前
|
安全 前端开发 网络安全
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
【Azure App Service】访问App Service应用报错 SSL: WRONG_VERSION_NUMBER
|
13天前
|
Web App开发 Java 视频直播
FFmpeg开发笔记(四十九)助您在毕业设计中脱颖而出的几个流行APP
对于软件、计算机等专业的毕业生,毕业设计需实现实用软件或APP。新颖的设计应结合最新技术,如5G时代的音视频技术。示例包括: 1. **短视频分享APP**: 集成FFmpeg实现视频剪辑功能,如添加字幕、转场特效等。 2. **电商购物APP**: 具备直播带货功能,使用RTMP/SRT协议支持流畅直播体验。 3. **同城生活APP**: 引入WebRTC技术实现可信的视频通话功能。这些应用不仅实用,还能展示开发者紧跟技术潮流的能力。
36 4
FFmpeg开发笔记(四十九)助您在毕业设计中脱颖而出的几个流行APP
|
7天前
|
移动开发 小程序 JavaScript
uni-app开发微信小程序
本文详细介绍如何使用 uni-app 开发微信小程序,涵盖需求分析、架构思路及实施方案。主要功能包括用户登录、商品列表展示、商品详情、购物车及订单管理。技术栈采用 uni-app、uView UI 和 RESTful API。文章通过具体示例代码展示了从初始化项目、配置全局样式到实现各页面组件及 API 接口的全过程,并提供了完整的文件结构和配置文件示例。此外,还介绍了微信授权登录及后端接口模拟方法,确保项目的稳定性和安全性。通过本教程,读者可快速掌握使用 uni-app 开发微信小程序的方法。
25 3
|
28天前
|
Web App开发 Android开发
FFmpeg开发笔记(四十六)利用SRT协议构建手机APP的直播Demo
实时数据传输在互联网中至关重要,不仅支持即时通讯如QQ、微信的文字与图片传输,还包括音视频通信。一对一通信常采用WebRTC技术,如《Android Studio开发实战》中的App集成示例;而一对多的在线直播则需部署独立的流媒体服务器,使用如SRT等协议。SRT因其优越的直播质量正逐渐成为主流。本文档概述了SRT协议的使用,包括通过OBS Studio和SRT Streamer进行SRT直播推流的方法,并展示了推流与拉流的成功实例。更多细节参见《FFmpeg开发实战》一书。
37 1
FFmpeg开发笔记(四十六)利用SRT协议构建手机APP的直播Demo