【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误

简介: 【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误

问题描述

Python Flash应用上云,本地Git部署(https://docs.azure.cn/zh-cn/app-service/quickstart-python?tabs=flask%2Cwindows%2Cazure-cli%2Clocal-git-deploy%2Cdeploy-instructions-azportal%2Cterminal-bash%2Cdeploy-instructions-zip-azcli),遇见两类问题。

1: src refspec master does not match any

> git push azure master

error: src refspec master does not match any

error: failed to push some refs to 'https://xxxxxxxxx.scm.chinacloudsites.cn:443/xxxxxxxxx.git'

2:remote: Error - Changes committed to remote repository but deployment to website failed.

> git push azure main   
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 295 bytes | 295.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Deploy Async
remote: The current deployment branch is 'master', but nothing has been pushed to it
remote: Error - Changes committed to remote repository but deployment to website failed.
remote: Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
remote:    at Kudu.Console.Program.PerformDeploy(String appRoot, String wapTargets, String deployer, String lockPath, IEnvironment env, IDeploymentSettingsManager settingsManager, TraceLevel level, ITracer tracer, ITraceFactory traceFactory, IOperationLock deploymentLock, IBuildService buildService) in /tmp/KuduLite/Kudu.Console/Program.cs:line 220
remote:    at Kudu.Console.Program.Main(String[] args) in /tmp/KuduLite/Kudu.Console/Program.cs:line 95
remote: Aborted (core dumped)
To https://xxxxxxxxx.scm.chinacloudsites.cn:443/xxxxxxxxx.git
   223b3cf..6250814  main -> main

 

问题解答

面对问题,反复尝试。

继续使用 " git push azure master " " git push azure main " 指令push本地文件到App Service, 但总是显示 error : xxxx 或 Everything up-to-date 。 根本无法完成App Service的部署操作。

对比文档,对有默认的 master  branch变换为main,检查官方文档中,需要设置DEPLOYMENT_BRANCH参数,并设置为 main。

应用服务的默认部署分支是 master,但许多 Git 存储库将从 master 移至 main。 可以在推送中指定本地分支名称和远程分支名称之间的对应关系(如下所示),也可以配置 DEPLOYMENT_BRANCH 应用设置

配置完成后,通过对本地文件修改,使得 push 时不再是 everything up-to-date。

# 添加修改的内容

git add  .

# 提交修改到本地 Ropes

git commit -m "update"

# Push到App Service Repostory

git push azure main

此次,输出内容完成,并明确提示Deployment successful。

PS C:\MyWorkPlace\CaseFile\CASE\msdocs-python-flask-webapp-quickstart> git push azure main
Everything up-to-date
PS C:\MyWorkPlace\CaseFile\CASE\msdocs-python-flask-webapp-quickstart> git add  .
PS C:\MyWorkPlace\CaseFile\CASE\msdocs-python-flask-webapp-quickstart> git commit -m "update"
[main a7afc79] update
 1 file changed, 1 insertion(+), 1 deletion(-)
PS C:\MyWorkPlace\CaseFile\CASE\msdocs-python-flask-webapp-quickstart> git push azure main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 283 bytes | 283.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Deploy Async
remote: Updating branch 'main'.
remote: Updating submodules.
remote: Preparing deployment for commit id 'a7afc79780'.
remote: PreDeployment: context.CleanOutputPath False
remote: PreDeployment: context.OutputPath /home/site/wwwroot
remote: Repository path is /home/site/repository
remote: Running oryx build...
remote: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
remote: You can report issues at https://github.com/Microsoft/Oryx/issues
remote: 
remote: Oryx Version: 0.2.20230508.1, Commit: 7fe2bf39b357dd68572b438a85ca50b5ecfb4592, ReleaseTagName: 20230508.1
remote: 
remote: Build Operation ID: 749d23a7e7e13313
remote: Repository Commit : a7afc79780d8f7246cb32368c547078f5ffb36b7
remote: OS Type           : buster
remote: Image Type        : githubactions
remote: 
remote: Detecting platforms...
remote: .
remote: Detected following platforms:
remote:   python: 3.9.18
remote: Version '3.9.18' of platform 'python' is not installed. Generating script to install it...
remote: 
remote: Using intermediate directory '/tmp/8dc73196223c40d'.
remote: 
remote: Copying files to the intermediate directory...
remote: Done in 1 sec(s).
remote: 
remote: Source directory     : /tmp/8dc73196223c40d
remote: Destination directory: /home/site/wwwroot
remote:
remote: 
remote: Downloading and extracting 'python' version '3.9.18' to '/tmp/oryx/platforms/python/3.9.18'...
remote: Detected image debian flavor: buster.
remote: Downloaded in 3 sec(s).
remote: Verifying checksum...
remote: Extracting contents...
remote: .......
remote: performing sha512 checksum for: python...
remote: Done in 16 sec(s).
remote: 
remote: Python Version: /tmp/oryx/platforms/python/3.9.18/bin/python3.9
remote: Creating directory for command manifest file if it does not exist
remote: Removing existing manifest file
remote: Python Virtual Environment: antenv
remote: Creating virtual environment...
remote: ...............
remote: Activating virtual environment...
remote: Running pip install...
remote: ........
remote: [06:54:16+0000] Collecting Flask==2.2.2
remote: [06:54:17+0000]   Downloading Flask-2.2.2-py3-none-any.whl (101 kB)
remote: [06:54:17+0000]      ΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöü 101.5/101.5 kB 626.3 kB/s eta 0:00:00
remote: [06:54:17+0000] Collecting gunicorn
remote: [06:54:17+0000]   Downloading gunicorn-22.0.0-py3-none-any.whl (84 kB)
remote: [06:54:17+0000]      ΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöü 84.4/84.4 kB 2.6 MB/s eta 0:00:00
remote: [06:54:18+0000] Collecting Werkzeug==2.2.2
remote: [06:54:18+0000]   Downloading Werkzeug-2.2.2-py3-none-any.whl (232 kB)
remote: [06:54:18+0000]      ΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöü 232.7/232.7 kB 2.0 MB/s eta 0:00:00
remote: [06:54:18+0000] Collecting Jinja2>=3.0
remote: [06:54:18+0000]   Downloading jinja2-3.1.4-py3-none-any.whl (133 kB)
remote: [06:54:18+0000]      ━━━━━━━━━━━━━━��━━━━━━━━━━━━━━━━━━━━━━━━ 133.3/133.3 kB 9.3 MB/s eta 0:00:00
remote: [06:54:18+0000] Collecting click>=8.0
remote: [06:54:19+0000]   Downloading click-8.1.7-py3-none-any.whl (97 kB)
remote: [06:54:19+0000]      ΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöü 97.9/97.9 kB 8.9 MB/s eta 0:00:00
remote: [06:54:19+0000] Collecting importlib-metadata>=3.6.0
remote: [06:54:19+0000]   Downloading importlib_metadata-7.1.0-py3-none-any.whl (24 kB)
remote: [06:54:19+0000] Collecting itsdangerous>=2.0
remote: [06:54:20+0000]   Downloading itsdangerous-2.2.0-py3-none-any.whl (16 kB)
remote: [06:54:20+0000] Collecting MarkupSafe>=2.1.1
remote: [06:54:20+0000]   Downloading MarkupSafe-2.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
remote: [06:54:21+0000] Collecting packaging
remote: [06:54:21+0000]   Downloading packaging-24.0-py3-none-any.whl (53 kB)
remote: [06:54:21+0000]      ΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöüΓöü 53.5/53.5 kB 4.0 MB/s eta 0:00:00
remote: [06:54:21+0000] Collecting zipp>=0.5
remote: [06:54:21+0000]   Downloading zipp-3.18.1-py3-none-any.whl (8.2 kB)
remote: [06:54:22+0000] Installing collected packages: zipp, packaging, MarkupSafe, itsdangerous, click, Werkzeug, Jinja2, importlib-metadata, gunicorn, Flask
remote: [06:54:24+0000] Successfully installed Flask-2.2.2 Jinja2-3.1.4 MarkupSafe-2.1.5 Werkzeug-2.2.2 click-8.1.7 gunicorn-22.0.0 importlib-metadata-7.1.0 itsdangerous-2.2.0 packaging-24.0 zipp-3.18.1
remote: 
remote: [notice] A new release of pip is available: 23.0.1 -> 24.0
remote: Not a vso image, so not writing build commands
remote: Not a vso image, so not writing build commands
remote: Preparing output...
remote:
remote: Copying files to destination directory '/tmp/_preCompressedDestinationDir'...
remote: Done in 4 sec(s).
remote: Compressing content of directory '/tmp/_preCompressedDestinationDir'...
remote: Copied the compressed output to '/home/site/wwwroot'
remote:
remote: Removing existing manifest file
remote: Creating a manifest file...
remote: Manifest file created.
remote: Copying .ostype to manifest output directory.
remote:
remote: Done in 60 sec(s).
remote: Running post deployment command(s)...
remote:
remote: Generating summary of Oryx build
remote: Parsing the build logs
remote: Found 0 issue(s)
remote:
remote: Build Summary :
remote: ===============
remote: Errors (0)
remote: Warnings (0)
remote:
remote: Triggering recycle (preview mode disabled).
remote: Deployment successful. deployer =  deploymentPath =
remote: Deployment Logs : 'https://********.scm.chinacloudsites.cn/newui/jsonviewer?view_url=/api/deployments/a7afc79780d8f7246cb32368c547078f5ffb36b7/log'
To https://********.scm.chinacloudsites.cn:443/********.git
   6250814..a7afc79  main -> main

 

 

参考资料

快速入门:将 Python(Django 或 Flask)Web 应用部署到 Azure应用服务 : https://docs.azure.cn/zh-cn/app-service/quickstart-python?tabs=flask%2Cwindows%2Cazure-cli%2Clocal-git-deploy%2Cdeploy-instructions-azportal%2Cterminal-bash%2Cdeploy-instructions-zip-azcli

更改部署分支 : https://docs.azure.cn/zh-cn/app-service/deploy-local-git?tabs=cli#change-deployment-branch

 

目录
打赏
0
0
1
0
203
分享
相关文章
【Azure Developer】分享两段Python代码处理表格(CSV格式)数据 : 根据每列的内容生成SQL语句
本文介绍了使用Python Pandas处理数据收集任务中格式不统一的问题。针对两种情况:服务名对应多人拥有状态(1/0表示),以及服务名与人名重复列的情况,分别采用双层for循环和字典数据结构实现数据转换,最终生成Name对应的Services列表(逗号分隔)。此方法高效解决大量数据的人工处理难题,减少错误并提升效率。文中附带代码示例及执行结果截图,便于理解和实践。
【Azure App Service】基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?
基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?Web App Linux 默认使用的 Nginx 版本是由平台预定义的,无法更改这个版本。
144 77
Linux 手动安装快速部署 LNMP 环境实战
本文详细记录了在阿里云ECS上手动搭建LNMP环境的过程,系统选用Ubuntu 24.04。主要内容包括:1) 使用`apt`安装Nginx和MySQL,并更新软件源;2) 编译安装PHP 8.4.5,配置PHP-FPM及环境路径;3) 配置MySQL root用户密码;4) 调整Nginx支持PHP解析并测试整体环境。通过此过程,重现手动配置服务器的细节,帮助熟悉各组件的安装与协同工作。
Linux服务器部署docker windows
在当今软件开发中,Docker成为流行的虚拟化技术,支持在Linux服务器上运行Windows容器。流程包括:1) 安装Docker;2) 配置支持Windows容器;3) 获取Windows镜像;4) 运行Windows容器;5) 验证容器状态。通过这些步骤,你可以在Linux环境中顺利部署和管理Windows应用,提高开发和运维效率。
82 1
【Azure Developer】编写Python SDK代码实现从China Azure中VM Disk中创建磁盘快照Snapshot
本文介绍如何使用Python SDK为中国区微软云(China Azure)中的虚拟机磁盘创建快照。通过Azure Python SDK的Snapshot Class,指定`location`和`creation_data`参数,使用`Copy`选项从现有磁盘创建快照。代码示例展示了如何配置Default Azure Credential,并设置特定于中国区Azure的`base_url`和`credential_scopes`。参考资料包括官方文档和相关API说明。
Linux 主要应用领域的归纳
服务器领域 Linux在服务器领域的应用是其最为广泛和成熟的领域之一。由于其开源、稳定、高效和安全的特性,Linux成为许多企业服务器的首选操作系统。 Web服务器:Linux是Web服务器的理想选择,因为它支持Apache、Nginx等流行的Web服务器软件,这些软件在Linux上运行稳定且性能卓越。Linux服务器可以高效地处理大量并发请求,提供快速、可靠的Web服务。 数据库服务器:Linux也广泛用于数据库服务器,如MySQL、PostgreSQL和Oracle等数据库管理系统在Linux上运行良好。Linux的稳定性和安全性使得它成为存储和管理敏感数据的理想平台。 邮件服务器:Lin
82 5
【手把手教你Linux环境下快速搭建Kafka集群】内含脚本分发教程,实现一键部署多个Kafka节点
本文介绍了Kafka集群的搭建过程,涵盖从虚拟机安装到集群测试的详细步骤。首先规划了集群架构,包括三台Kafka Broker节点,并说明了分布式环境下的服务进程配置。接着,通过VMware导入模板机并克隆出三台虚拟机(kafka-broker1、kafka-broker2、kafka-broker3),分别设置IP地址和主机名。随后,依次安装JDK、ZooKeeper和Kafka,并配置相应的环境变量与启动脚本,确保各组件能正常运行。最后,通过编写启停脚本简化集群的操作流程,并对集群进行测试,验证其功能完整性。整个过程强调了自动化脚本的应用,提高了部署效率。
【手把手教你Linux环境下快速搭建Kafka集群】内含脚本分发教程,实现一键部署多个Kafka节点
【Azure Developer】Python代码调用Graph API将外部用户添加到组,结果无效,也无错误信息
根据Graph API文档,在单个请求中将多个成员添加到组时,Python代码示例中的`members@odata.bind`被错误写为`members@odata_bind`,导致用户未成功添加。
63 10
快速部署WSL(Windows Subsystem for Linux)
WSL提供了一种轻量级的方法,使开发者能够在Windows上无缝运行Linux环境。通过本文介绍的步骤,可以快速安装、配置和使用WSL,以满足开发和测试的需求。
392 8

热门文章

最新文章