Azure Functions Python - 使用安装脚本部署导入自己的python包的项目

问题描述 投票:0回答:1

我编写了一个python包,并希望通过使用azure函数将包的功能共享到Internet,从而创建一些http触发函数。我自己的包有一个安装脚本,并安装了一些它依赖的python包。

在本地安装我自己的软件包后,在命令行上运行func host start时,本地项目工作正常。但是在部署azure函数项目时,我没有安装我自己的软件包。

项目有一个azure函数,(简化)看起来像这样:

from my_own_package import SomeModule # The import fails because my own package isn't installed
from xml.etree import ElementTree  

def main(req: func.HttpRequest) -> func.HttpResponse:
    result = SomeModule.doSomething()
    return func.HttpResponse(result, status_code=200)

如何确保我的软件包正在安装,如何在azure函数项目中包含我自己的软件包?

python azure azure-functions
1个回答
0
投票

当您创建Python函数应用程序时,它只附带该语言的基础包。但您可以轻松创建自己的虚拟环境并安装所需的所有软件包。 This is a stack answear解释了如何做到这一点。祝好运。

我希望有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.