You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署Azure Function App时遇底层压缩例程加载错误求助

解决Azure Functions部署时"The underlying compression routine could not be loaded correctly"错误

问题场景

在VS Code中执行Azure Functions部署命令:

func azure functionapp publish [the function app name]

出现错误输出:

Getting site publishing info...
[2025-04-23T12:26:20.365Z] Starting the function app deployment...
Creating archive for current directory...
Performing remote build for functions project.
Deleting the old .python_packages directory
The underlying compression routine could not be loaded correctly.

已完成的验证步骤:

  • 使用PowerShell的ls命令确认处于目标函数应用项目目录,项目文件结构符合要求;
  • 检查host.json、local.settings.json配置无误;
  • requirements.txt包含azure-functions模块;
  • Azure函数应用与本地项目均使用Python 3.10;
  • 确认Azure函数应用环境变量配置齐全;
  • 已安装最新版az cli(2.71.0)和Azure Core Tools(4.0.7030);
  • 已执行az login完成登录。

解决方案

1. 修复本地压缩库依赖

该错误多与系统压缩库(如zlib)加载失败相关,针对不同系统操作:

  • Windows系统:
    • 安装对应Python版本的Visual C++ Redistributable运行时库;
    • 重启VS Code和PowerShell终端,确保环境变量生效;
  • Linux/macOS系统:
    • 安装zlib库:Debian/Ubuntu执行sudo apt-get install zlib1g-dev,macOS执行brew install zlib;
    • 重新安装Python 3.10,确保编译时正确链接zlib库。

2. 改用本地构建部署

跳过远程构建的压缩环节,先本地构建再部署:

  1. 本地构建项目:
func pack --build-native-deps --python
  1. 部署构建好的压缩包:
az functionapp deployment source config-zip -g <resource-group-name> -n <function-app-name> --src .\<your-pack-file>.zip

3. 清理缓存与临时文件

  • 删除项目目录下的.python_packages、__pycache__文件夹;
  • 删除Azure Core Tools临时缓存:
    • Windows路径:%LOCALAPPDATA%\AzureFunctionsTools
    • Linux/macOS路径:~/.azurefunctions
  • 重新执行部署命令。

4. 降级Azure Core Tools版本

新版本工具可能存在压缩库兼容性问题,尝试降级到稳定版本:

  1. 卸载当前版本:
npm uninstall -g azure-functions-core-tools@4
  1. 安装指定稳定版本:
npm install -g azure-functions-core-tools@4.0.6518 --unsafe-perm true

内容的提问来源于stack exchange,提问作者ralhpq1

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 07:57:12