python - 无法发布具有外部依赖项的azure python函数应用程序(不在索引中)

标签 python azure azure-functions python-wheel

我有一个简单的 python 模块 AdditionalLibrary ,我不想将其公开发布到任何地方。我还有一个 azure python 无服务器功能应用程序 ExamplePythonServerlessFunction我想在 Azure 上发布。

我遵循了官方文档:

和一个过时的页面 https://prmadi.com/install-python-modules-on-azure-app-services/

最后,我的 azure 函数项目中有一个 wheelhouse 目录,其中包含我需要的每个依赖项的 *.whl 文件。我尝试在 requirments.txt 文件中添加额外的标志,以使用 wheelhouse 目录而不是索引。这是我的 requirments.txt 文件的内容。

--no-index --find-links file://wheelhouse
Additional-Library==1.0
azure-functions==1.0.0b4
azure-functions-worker==1.0.0b6
grpcio==1.20.1
grpcio-tools==1.20.1
protobuf==3.6.1
six==1.11.0

在发布应用程序期间:

$ func azure functionapp publish ${APP_NAME} --build-native-deps

我收到错误:

  Url 'file://wheelhouse' is ignored: it is neither a file nor a directory.

并且我无法安装依赖项。这样的方式正确吗?如何为 azure function app 安装一些额外的依赖项。

任何帮助和建议将不胜感激。

最佳答案

我一直在这样做:

import os
import sys
sys.path.append(os.path.abspath(os.path.join(os.path.dirname( __file__ ), '../../../az/Lib/site-packages')))
from azure.storage.cloudstorageaccount import CloudStorageAccount,AccountPermissions,Services,ResourceTypes
from azure.storage.blob import BlockBlobService

因此您可以在函数中创建一个目录并将其添加到路径并从该路径导入模块。

关于python - 无法发布具有外部依赖项的azure python函数应用程序(不在索引中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56011364/

相关文章:

python - 使用 Binascii Hexlify 输入

azure - 如何处理 Azure Web 应用程序版本控制?

azure - 哪个测试运行程序可与 VSTS 和 ASP.NET Core 配合使用?

azure-functions - 无法在 Visual Studio Mac 中更新 Azure Functions 核心工具

azure-functions - Azure Functions 使用静态属性测试函数

python - 无法理解 PyQt 中的一行代码

python - TypeError: __init__() 采用 0 个位置参数,但给出了 1 个

python - 用 Pandas 连接两列

.net - 如何在 Windows Azure 上获取代码证书

python - 在 azure 函数中找不到本地模块