根据Azure文档-https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-decorators#folder-structure他们在repo中有所有的文件,但是如果我想在同一个函数应用程序中有一堆不同的函数,我如何将它们组织在文件夹中?
6qfn3psc1#
为了在同一个函数应用程序中部署不同的函数,请参考以下步骤:-根据**Function V2 programming model**上的这个Microsoft Blog。为了减少多个线程和文件管理,你需要在同一个function_app.py中添加多个Azure Function触发器,并使用多个输出和输入绑定:-x1c 0d1x的数据
Function V2 programming model
**My function_app.py with Http_Trigger and Queue_Trigger binding and decorators:-
import azure.functions as func app = func.FunctionApp() @app.function_name(name="HttpTrigger1") @app.route(route="hello") # HTTP Trigger def test_function(req: func.HttpRequest) -> func.HttpResponse: return func.HttpResponse("HttpTrigger1 function processed a request!!!") @app.queue_trigger(arg_name="azqueue", queue_name="testqueue", connection="testqueue") def queue_trigger(azqueue: func.QueueMessage): logging.info('Python Queue trigger processed a message: %s', azqueue.get_body().decode('utf-8'))
字符串
本地输出:-
的我在我的Function应用程序中部署了这个函数,两个触发器都是可见的:-
的
[ { "name": "FUNCTIONS_EXTENSION_VERSION", "value": "~4", "slotSetting": false }, { "name": "FUNCTIONS_WORKER_RUNTIME", "value": "python", "slotSetting": false }, { "name": "APPLICATIONINSIGHTS_CONNECTION_STRING", "value": "InstrumentationKey=xxxxxxxxd825aa;IngestionEndpoint=https://australiacentral-0.in.applicationinsights.azure.com/;LiveEndpoint=https://australiacentral.livediagnostics.monitor.azure.com/", "slotSetting": false }, { "name": "AzureWebJobsStorage", "value": "DefaultEndpointsProtocol=https;AccountName=vsidrgb561;AccountKey=xxxxxxxAStiabOIw==;EndpointSuffix=core.windows.net", "slotSetting": false }, { "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", "value": "DefaultEndpointsProtocol=https;AccountName=vsidrgb561;AccountKey=xxxxxxxx73S3IgpyqEx+AStiabOIw==;EndpointSuffix=core.windows.net", "slotSetting": false }, { "name": "WEBSITE_CONTENTSHARE", "value": "siliconfunc98bdd9", "slotSetting": false }, { "name": "ENABLE_ORYX_BUILD", "value": "true", "slotSetting": false }, { "name": "SCM_DO_BUILD_DURING_DEPLOYMENT", "value": "1", "slotSetting": false }, { "name": "BUILD_FLAGS", "value": "UseExpressBuild", "slotSetting": false }, { "name": "XDG_CACHE_HOME", "value": "/tmp/.cache", "slotSetting": false }, { "name": "testqueue", "value": "DefaultEndpointsProtocol=https;AccountName=valleystrg989;AccountKey=xxxxxxxxFKHm/A==;EndpointSuffix=core.windows.net", "slotSetting": false }, { "name": "AzureWebJobsFeatureFlags", "value": "EnableWorkerIndexing", "slotSetting": false } ]
AzureWebJobsFeatureFlags:EnableWorkerIndexing
的数据以下设置是在功能应用程序中加载功能的必备设置。
1条答案
按热度按时间6qfn3psc1#
为了在同一个函数应用程序中部署不同的函数,请参考以下步骤:-
根据**
Function V2 programming model
**上的这个Microsoft Blog。为了减少多个线程和文件管理,你需要在同一个function_app.py中添加多个Azure Function触发器,并使用多个输出和输入绑定:-x1c 0d1x的数据
**My function_app.py with Http_Trigger and Queue_Trigger binding and decorators:-
字符串
本地输出:-
的
我在我的Function应用程序中部署了这个函数,两个触发器都是可见的:-
的
的数据
以下设置是在功能应用程序中加载功能的必备设置。
的