Python Azure Function V2部署后未在Azure Portal显示求助
Python Azure Function V2通过GitHub部署后函数未在Azure Portal显示
我尝试使用新版Python Azure Function V2,通过GitHub源代码控制部署,但函数未在Azure Portal中显示。已在本地设置中配置AzureWebJobsFeatureFlags: "EnableWorkerIndexing",相关文件结构、代码及配置如下:
文件结构
azure_app - monitoring_weekly - function_app.py - file1.py - file2.py - file3.py - file4.py - file5.py - host.json - requirements.txt
Function_app.py代码
import azure.functions as func import os import datetime import logging import sys import importlib.util # Azure function timer. To alter timer cadence see function.json file app = func.FunctionApp() @app.function_name(name="monitoring_weekly") @app.schedule(schedule="0 5 * * 1", arg_name="mytimer", run_on_startup=True, use_monitor=True) def main(mytimer: func.TimerRequest) -> None: utc_timestamp = datetime.datetime.utcnow().replace( tzinfo=datetime.timezone.utc).isoformat() if mytimer.past_due: logging.info('The timer is past due!') logging.info('Python timer trigger function ran at %s', utc_timestamp) def run_script(script_name): script_path = os.path.join(os.path.dirname(__file__), f'{script_name}') s = importlib.util.spec_from_file_location(script_name, script_path) m = importlib.util.module_from_spec(s) sys.modules[s.name] = m s.loader.exec_module(m) def batch_execution(file_list): exceptions = [] #store errors for file in file_list: try: run_script(file) except Exception as e: exceptions.append(e) else: print('Success') return exceptions #list of scripts running in function, if adding new script add to list. file_list = ['file1.py', 'file2.py', 'file3.py', 'file4.py', 'file5.py'] batch_execution(file_list)
host.json配置
{ "version": "2.0", "logging": { "applicationInsights": { "samplingSettings": { "isEnabled": true, "excludedTypes": "Request" } } }, "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[4.*, 5.0.0)" } }
requirements.txt内容
azure-functions sqlalchemy snowflake-sqlalchemy snowflake-connector-python sparkpost tabulate pandas runtime version: 4.24.4.4
内容的提问来源于stack exchange,提问作者Mitchell.Laferla
相关产品推荐
相关产品推荐

