gpt4 book ai didi

Python Azure Function 部署(Oryx 构建)在 "Running pip install..."步骤上挂起

转载 作者:行者123 更新时间:2023-12-03 03:21:27 26 4
gpt4 key购买 nike

我正在尝试将 Azure Function 部署到生产环境。

本地环境:

  • Windows 10
  • VS 代码 1.82.2
  • Python 3.9.10
  • Azure 函数核心工具 4.0.5390

Azure 环境:

  • 两个功能应用(开发/产品)
  • 均使用运行时版本 ~4
  • 两者都在 P2v2 应用服务计划上运行。

问题:从本地环境部署到 Azure 时,VS Code 输出窗口显示构建进展到“正在运行 pip install...”步骤,但没有进一步。它永远不会完成:

11:53:56 PM <function name removed>: Starting deployment...
11:53:56 PM <function name removed>: Creating zip package...
11:54:00 PM <function name removed>: Zip package size: 17.6 MB
11:54:05 PM <function name removed>: Fetching changes.
11:54:06 PM <function name removed>: Cleaning up temp folders from previous zip deployments and extracting pushed zip file <removed>.zip (16.84 MB) to /tmp/zipdeploy/extracted
11:54:09 PM <function name removed>: Updating submodules.
11:54:10 PM <function name removed>: Preparing deployment for commit id <removed>.
11:54:10 PM <function name removed>: PreDeployment: context.CleanOutputPath False
11:54:10 PM <function name removed>: PreDeployment: context.OutputPath /home/site/wwwroot
11:54:10 PM <function name removed>: Repository path is /tmp/zipdeploy/extracted
11:54:10 PM <function name removed>: Running oryx build...
11:54:10 PM <function name removed>: Command: oryx build /tmp/zipdeploy/extracted -o /tmp/build/expressbuild --platform python --platform-version 3.9.7 -i <removed> -p packagedir=.python_packages/lib/site-packages
11:54:11 PM <function name removed>: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
11:54:11 PM <function name removed>: You can report issues at https://github.com/Microsoft/Oryx/issues
11:54:11 PM <function name removed>: Oryx Version: 0.2.20230508.1, Commit: 7fe2bf39b357dd68572b438a85ca50b5ecfb4592, ReleaseTagName: 20230508.1
11:54:11 PM <function name removed>: Build Operation ID: <removed>
11:54:11 PM <function name removed>: Repository Commit : <removed>
11:54:11 PM <function name removed>: OS Type : bullseye
11:54:11 PM <function name removed>: Image Type : githubactions
11:54:11 PM <function name removed>: Detecting platforms...
11:54:12 PM <function name removed>: Detected following platforms:
11:54:12 PM <function name removed>: python: 3.9.7
11:54:12 PM <function name removed>: Using intermediate directory <removed>.
11:54:12 PM <function name removed>: Copying files to the intermediate directory...
11:54:12 PM <function name removed>: Done in 0 sec(s).
11:54:12 PM <function name removed>: Source directory : <removed>
11:54:12 PM <function name removed>: Destination directory: /tmp/build/expressbuild
11:54:13 PM <function name removed>: Python Version: /tmp/oryx/platforms/python/3.9.7/bin/python3.9
11:54:13 PM <function name removed>: Creating directory for command manifest file if it does not exist
11:54:13 PM <function name removed>: Removing existing manifest file
11:54:13 PM <function name removed>: Running pip install...

我已经确认这是部署到 Azure 中的开发应用程序和产品应用程序时的行为。

我尝试过但没有运气的事情:

  • 将 VS Code 升级到最新版本
  • 将 Azure Function Core Tools 升级到最新版本
  • 通过 Azure 门户的 Azure Function 边栏选项卡的部署中心中的“外部 Git”连接启动部署。执行此操作时,Azure 门户中的部署日志同样显示构建进度为“正在运行 pip install...”,但仅此而已。
  • 删除对requirements.txt的最新更改,从而将其返回到已知的工作状态

有什么想法吗?

最佳答案

Python Azure Function deployment (Oryx build) hangs on "Running pip install..." step: -

当您的 Python 函数具有大量依赖项并且安装 pip 需要大量时间时,就会出现此类问题。

需要检查以下内容:

  • 首先,检查 Azure 函数核心工具扩展是否是最新的。检查是否与您使用的VScode版本兼容(如果已更新)。

  • 如果需要,请升级 pip。要升级 pip,请使用

    py -m pip install --upgrade pip
  • 检查并清除Pip缓存,因为它默认将下载的包缓存在本地缓存中。当缓存出现故障时,可能会出现问题。pip 缓存清除

  • 尝试使用虚拟环境来执行 Python 函数,以隔离 Python 包依赖项。在 VScode 终端中激活虚拟环境。

    详细步骤参见 doc给定。

我尝试创建一个 Python Azure 函数并使用 VScode 进行部署,如图所示。它按预期工作。

部署成功:

enter image description here

enter image description here

注意:如果问题仍然存在,请重新启动 VScode IDE 并再次尝试部署。

引用Troubleshoot函数部署错误。

关于Python Azure Function 部署(Oryx 构建)在 "Running pip install..."步骤上挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77192092/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com