我正在构建一个python函数,我需要在代码中添加自定义模块。我的azure函数如下所示:
import logging
import sys
from sys import path
import os
import time
sys.path.insert(0, './myFunctionFolderName') // Try to insert it as a standard python library.
import azure.functions as func
from myCustomModule.models import someFunctionName
def main(req: func.HttpRequest) -> func.HttpResponse:
name = "My new function"
testing_variable = someFunctionName()
return func.HttpResponse(f"Function executed {name}")]
我所做的是将我的函数文件夹作为标准路径插入,这样python也会在该文件夹中查找库。此函数在使用visualstudio代码的本地环境中可以完美地工作。但是,当我部署并运行它时,它抛出了找不到的myCustomModule
。另一条信息是我无法访问Kudu(终端),因为我的Linux消费计划中不支持它。我不知道我错过了什么。请不要,因为它不是一个标准库,我不能把它添加到要求.txt. 另外请注意,我的函数文件夹有我的函数脚本文件和我的自定义模块,因此它们与azurepython模板中应该位于同一个文件夹中。在
使用绝对路径而不是相对路径。在
跟随对我有用
相关问题 更多 >
编程相关推荐