python - Microsoft.Azure.WebJobs.Script : Architecture Arm64 is not supported for language python (issue on Mac M1 Chip)

标签 python azure sqlalchemy azure-functions

我的笔记本电脑是 MacBook Pro(16 英寸,2021 年)Apple M1 Max。

我想使用 Python 运行 Azure 函数。

目前,Azure function Core 工具不支持 ARM64 设备上的 Python 函数开发。要在M1芯片的Mac上开发Python功能,必须在模拟的x86环境中运行。要了解更多信息,see x86 emulation on ARM64

我已经按照说明进行操作了。

Install the Azure Functions Core Tools

到目前为止,我做到了:

  1. 安装 Homebrew

  2. 使用 Rosetta 打开终端。

  3. 还有Enable emulation in Visual Studio Code

  4. 设置.json

    "azureFunctions.deploySubpath": ".",
    "azureFunctions.scmDoBuildDuringDeployment": true,
    "azureFunctions.pythonVenv": ".venv",
    "azureFunctions.projectLanguage": "Python",
    "azureFunctions.projectRuntime": "~4",
    "debug.internalConsoleOptions": "neverOpen",
    "terminal.integrated.profiles.osx": {
       "rosetta": {
         "path": "arch",
         "args": ["-x86_64", "zsh", "-l"],
         "overrideName": true
       }
     }
}
  • 我的项目所在的根文件夹中有 .zshrc 文件。
  • # rosetta terminal setup
    if [ $(arch) = "i386" ]; then
        alias python="/usr/local/bin/python3"
        alias brew86='/usr/local/bin/brew'
        alias pyenv86="arch -x86_64 pyenv"
        alias func="/usr/local/Cellar/azure-functions-core-tools@4/4.0.5095/func"
    fi
    

    所以在 VS 代码编辑器中,我有 Rosetta 终端。运行 arch 将显示模拟 ARM64 的 i386。

  • azure-functions-core-tools@4/4.0.5095 文件夹从 opt/homebrew/Cellar/azure-functions-core-tools@4 复制到/usr/local/Cellar/azure-functions-core-tools@4/4.0.5095/func" 因为如果我从终端安装 azure-functions-core-tools@4,它总是会转到自制文件夹。
  • 如果在 Rosetta 终端中运行 func host start,则会显示错误

    无法初始化工作程序提供程序:/usr/local/Cellar/azure-functions-core-tools@4/4.0.5095/workers/python

    Microsoft.Azure.WebJobs.Script:Python 语言不支持架构 Arm64。 无法初始化工作程序提供程序:/usr/local/Cellar/azure-functions-core-tools@4/4.0.5095/workers/python......(跳过)

    我已经遵循了网上的任何解决方案,大多数都是通过这种方式在M1芯片上运行azure功能。

    我是否做错了什么或者遗漏了什么?

    4/13更新 主机.json

    {
      "version": "2.0",
      "logging": {
        "applicationInsights": {
          "samplingSettings": {
            "isEnabled": true,
            "excludedTypes": "Request"
          }
        }
      },
      "extensionBundle": {
        "id": "Microsoft.Azure.Functions.ExtensionBundle",
        "version": "[3.*, 4.0.0)"
      }
    }
    

    最佳答案

    我广泛寻找解决方案(Azure 函数不支持 Apple Silicon 上的 Python),并发现此评论提供了一个很好的解决方法,无需依赖仿真:https://github.com/Azure/azure-functions-python-worker/issues/915#issuecomment-1342319719

    您必须修改自制 azure 函数文件夹的路径(我的当前版本为 4.0.5198,而说明适用于 4.0.4915)。

    每当 Azure Functions 的自制程序更新时,您还需要重复这些步骤。

    关于python - Microsoft.Azure.WebJobs.Script : Architecture Arm64 is not supported for language python (issue on Mac M1 Chip),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75988713/

    相关文章:

    python - 如何在 Python 中创建嵌套字典?

    python - 动态嵌套Python字典

    java - ms Graph api(beta) 访问被拒绝

    python - sql alchemy 和 postgres 的连接池

    python - 在 Flask 中按文件分离 SQLAlchemy 模型

    python - 大小为 2GB 的数组在减法和除法运算时会引发内存错误

    python - 如何使用 TensorFlow 的 sketch RNN 教程对 QuickDraw 涂鸦进行分类?

    azure - 如何在Azure Application Insights中使用cloud/roleName上的过滤器?

    azure - 在 Azure Blob 容器中创建三个文件时,如何在 Azure 数据工厂中创建事件触发器?

    python - 我如何在 SQL 查询中伪造这些数据