我有一个简单的 python 模块 AdditionalLibrary ,我不想将其公开发布到任何地方。我还有一个 azure python 无服务器功能应用程序 ExamplePythonServerlessFunction我想在 Azure 上发布。
我遵循了官方文档:
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python
和一个过时的页面 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/