无法发布具有外部依赖项的Azure python函数应用程序(不在索引中) [英] Not able to publish azure python function app with external dependencies (not in index)

查看:53
本文介绍了无法发布具有外部依赖项的Azure python函数应用程序(不在索引中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an simple python module AdditionalLibrary, I do not want to publish it nowhere public. I have also an azure python serverless function app ExamplePythonServerlessFunction I want to publish on azure.

我遵循了官方文件:

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

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

Finally I have a wheelhouse directory in my azure function project containing *.whl files for every dependency I need. I try to put additional flags to my requirments.txt file to use wheelhouse directory instead of index. This is content of my requirments.txt file.

--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函数应用程序.

and I am not able to install dependencies. Is that way is correct? How can I install some additional dependencies to azure function app.

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

Any help and advice will be appreciated.

推荐答案

我一直在这样做:

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

因此您只需在函数中创建一个目录,然后将其添加到path并从该路径导入模块即可.

so you can just create a directory in your function and add it to path and import modules from that path.

这篇关于无法发布具有外部依赖项的Azure python函数应用程序(不在索引中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆