【问题标题】:Deployed Azure python function, can not run because 'azure.storage' module could not be found部署 Azure python 函数,无法运行,因为找不到“azure.storage”模块
【发布时间】:2019-06-06 17:12:30
【问题描述】:

部署我的 Python 函数应用程序后,当我尝试在 Azure 云上运行它时,它失败并出现以下错误:如何在运行应用程序服务的机器上安装 azure-storage?请帮忙。

将 azure.functions 导入为 func 导入日期时间

导入操作系统、uuid、sys 从 azure.storage.blob 导入 BlockBlobService,PublicAccess ...... ......

【问题讨论】:

  • 错误:-----执行函数时出现异常:Functions.HttpTrigger 结果:失败异常:ModuleNotFoundError:没有名为“azure.storage”的模块堆栈:文件“/usr/local/lib/ python3.6/site-packages/azure/functions_worker/dispatcher.py",第 230 行,在 _
  • 您是否有包含您的功能所需的包的 requirements.txt 文件? link to docs
  • 是的,这是txt文件的内容 azure-storage-blob==1.5.0 azure-storage-common==1.4.2 azure-storage-file==1.4.0 azure- storage-queue==1.4.0 azure-functions azure-functions-worker grpcio==1.14.1 grpcio-tools==1.14.1 protobuf==3.6.1 六==1.11.0
  • 然后如果我在 requirements.txt 中填充了上述内容,我会在部署时收到此错误:还原依赖项时出错。错误:无法安装 cryptography-2.7 依赖项:没有轮子的二进制依赖项不是支持的。使用 --build-native-deps 选项使用 Docker 容器自动构建和配置依赖项。更多信息aka.ms/func-python-publish
  • @Thmsdnnr 非常感谢您指出这一点。我实际上遵循了这一点并且没有工作。然而,在全新安装核心工具和 Docker 之后,我设法构建了包并运行了它。这是我使用的构建命令: func azure functionapp publish --build-native-deps

标签: python-3.x azure azure-functions


【解决方案1】:

连接到您的 Azure CLI,或者您也可以从 Azure 门户打开 Azure CLI。

创建存储帐户:

az storage account create --name --location --resource-group --sku Standard_LRS

例如:- az storage account create --name apistorage --location westindia --resource-group apiGroup --sku Standard_LRS

创建资源组:

az group create --name --location

例如:-
az group create --name apiGroup --location westindia

现在您可以从 CLI 创建您的 azure 函数:

例如:- az functionapp create --resource-group apiGroup --os-type Linux --consumption-plan-location westindia --runtime python --name ServiceName --storage-account apistorage

参考:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python

【讨论】:

  • 这实际上已经解决了。原来,我需要创建需求文件和 Docker 容器。
猜你喜欢
  • 2023-01-28
  • 2022-01-07
  • 1970-01-01
  • 1970-01-01
  • 2014-01-09
  • 1970-01-01
  • 1970-01-01
  • 2021-08-28
  • 2021-04-26
相关资源
最近更新 更多