gpt4 book ai didi

python - Azure功能部署失败: `Malformed SCM_RUN_FROM_PACKAGE when uploading built content.`

转载 作者:行者123 更新时间:2023-12-02 05:55:08 24 4
gpt4 key购买 nike

尝试使用 VS Code Azure Functions extension 部署 python 运行时 ( v3.6.9 ) Azure 函数。

我创建了这个函数,然后...

  1. 点击Upload来自扩展
  2. Create new function app in Azure (advanced)
  3. 输入了全局唯一的函数名称
  4. 已选择Python 3.6作为运行时
  5. 已选择Consumption托管计划
  6. 选择了一个现有资源组(专为本项目创建)
  7. 选择了一个现有存储帐户(专为本项目创建)
  8. 已选择Skip for now应用洞察
  9. 输出窗口显示“正在创建新函数应用”

...但是过程错误:

11:36:47 PM azblobtoawss3: Creating zip package...
11:36:47 PM azblobtoawss3: Starting deployment...
11:36:49 PM azblobtoawss3: Updating submodules.
11:36:49 PM azblobtoawss3: Preparing deployment for commit id '3a4998bc20'.
11:36:49 PM azblobtoawss3: Repository path is /tmp/zipdeploy/extracted
11:36:49 PM azblobtoawss3: Running oryx build...
11:36:49 PM azblobtoawss3: Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.6 -p packagedir=.python_packages/lib/python3.6/site-packages
11:36:50 PM azblobtoawss3: Build orchestrated by Microsoft Oryx, https://github.com/Microsoft/Oryx
11:36:51 PM azblobtoawss3: You can report issues at https://github.com/Microsoft/Oryx/issues
11:36:51 PM azblobtoawss3: Oryx Version : 0.2.20200114.13, Commit: 204922f30f8e8d41f5241b8c218425ef89106d1d, ReleaseTagName: 20200114.13
11:36:51 PM azblobtoawss3: Build Operation ID: |MIqvQZRaiqA=.6dffab29_
11:36:51 PM azblobtoawss3: Repository Commit : 3a4998bc205144f9998de05338412208
11:36:51 PM azblobtoawss3: Warning: An outdated version of python was detected (3.6.9). Consider updating.\nVersions supported by Oryx: https://github.com/microsoft/Oryx
11:36:51 PM azblobtoawss3: Source directory : /tmp/zipdeploy/extracted
11:36:51 PM azblobtoawss3: Destination directory: /home/site/wwwroot
11:36:51 PM azblobtoawss3: Python Version: /opt/python/3.6.9/bin/python3
11:36:51 PM azblobtoawss3: Running pip install...
11:36:51 PM azblobtoawss3: [06:36:51+0000] Collecting azure-functions
11:36:51 PM azblobtoawss3: [06:36:51+0000] Using cached https://files.pythonhosted.org/packages/5b/6d/67a219c38be7e4eae7c001a9bf83ab059dcf497644ccc6c5f696ea4155fa/azure_functions-1.2.1-py3-none-any.whl
11:36:51 PM azblobtoawss3: [06:36:51+0000] Installing collected packages: azure-functions
11:36:51 PM azblobtoawss3: [06:36:51+0000] Successfully installed azure-functions-1.2.1
11:36:51 PM azblobtoawss3: WARNING: You are using pip version 19.3.1; however, version 20.1.1 is available.
11:36:51 PM azblobtoawss3: You should consider upgrading via the 'pip install --upgrade pip' command.
11:36:51 PM azblobtoawss3: [06:36:51+0000] Cleaning up...
11:36:51 PM azblobtoawss3: Done in 1 sec(s).
11:36:51 PM azblobtoawss3: Done running pip install.
11:36:51 PM azblobtoawss3: Copying files to destination directory '/home/site/wwwroot'...
11:36:51 PM azblobtoawss3: Done in 0 sec(s).
11:36:51 PM azblobtoawss3: Removing existing manifest file
11:36:51 PM azblobtoawss3: Creating a manifest file...
11:36:51 PM azblobtoawss3: Manifest file created.
11:36:51 PM azblobtoawss3: Done in 1 sec(s).
11:36:53 PM azblobtoawss3: Running post deployment command(s)...
11:36:53 PM azblobtoawss3: Triggering recycle (preview mode disabled).
11:36:53 PM azblobtoawss3: Creating placeholder blob for linux consumption function app...
11:36:53 PM azblobtoawss3: **Malformed SCM_RUN_FROM_PACKAGE when uploading built content**.
11:37:04 PM azblobtoawss3: **Deployment failed**.

我也尝试过...

  • 右键单击“函数”项目
  • Deploy to Azure

...相同的结果。

EDIT1:还尝试根据 @hury-shen 的建议从 cli 执行远程构建:

(.venv) user@system:~/Documents/azureBlobToS3$ func azure functionapp publish azureblobtoawss3 --build remote

Getting site publishing info...
Remote build is a new feature added to function apps.
Your function app azureblobtoawss3 does not support remote build as it was created before August 1st, 2019.
Please use '--build local' or '--build-native-deps'.
For more information, please visit https://aka.ms/remotebuild

然后我继续使用 az functionapp update -g <RESOURCE_GROUP_NAME> -n <APP_NAME> 更新应用程序。相同的结果。

我还添加了列出的应用程序设置 here在 Linux 上启用远程构建。相同的结果。

然后我尝试运行 func azure functionapp publish <APP_NAME> --build local相反并得到错误:

There was an error restoring dependencies.   Could not find a version that satisfies the requirement pkg-resources (from -r /home/user/Documents/azureBlobToS3/requirements.txt (line 19)) (from versions: )
No matching distribution found for pkg-resources (from -r /home/user/Documents/azureBlobToS3/requirements.txt (line 19))
ERROR: ['/home/user/Documents/azureBlobToS3/.venv/bin/python3', '-m', 'pip', 'download', '-r', '/home/user/Documents/azureBlobToS3/requirements.txt', '--dest', '/tmp/azureworkerjv2xkb_k'] failed with exit code 1

然而 pip 显示 pkg-resources依赖性得到满足!

(.venv) user@system:~/Documents/azureBlobToS3$ pip install pkg-resources

Requirement already satisfied: pkg-resources in ./.venv/lib/python3.6/site-packages

编辑2:删除pkg-resources来自requirements.txt只是为了测试

我陷入了一个循环。无法远程构建,无法本地构建。

There was an error restoring dependencies. ERROR: cannot install cryptography-2.9.2 dependency: binary dependencies without wheels are not supported when building locally. Use the "--build remote" option to build dependencies on the Azure Functions build server, or "--build-native-deps" option to automatically build and configure the dependencies using a Docker container. More information at https://aka.ms/func-python-publish

还有其他人看到这个错误吗?如何排除故障?

最佳答案

通过扩展部署python函数经常会出现一些问题,所以我建议您使用命令将python函数从本地部署到azure。请引用以下步骤:

1.转到azure门户并创建一个函数应用程序(python)。

2. 单击 VS 代码中的“终端”按钮,打开“终​​端”窗口,然后运行以下命令生成“requirements.txt”,其中包含您安装的所有模块功能。

pip freeze > requirements.txt

enter image description here

3.通过运行以下命令将函数从本地部署到azure:

func azure functionapp publish <functionAppName> --build remote

enter image description here<functionAppName>是您刚才创建的函数应用程序的名称。运行此命令后,功能代码将从本地部署到azure,azure将根据我们上面生成的“requirements.txt”的内容安装模块。

希望对你有帮助~

关于python - Azure功能部署失败: `Malformed SCM_RUN_FROM_PACKAGE when uploading built content.` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62017288/

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