From ce8fda8f0d6dceff0e71941fbe0f93d4fdb0ca38 Mon Sep 17 00:00:00 2001 From: Steve Laing Date: Mon, 6 Jan 2025 17:53:22 +0000 Subject: [PATCH] Add function app which delegates requests to Flask --- function_app.py | 14 ++++++++++++++ host.json | 8 ++++++++ local.settings.json | 7 +++++++ 3 files changed, 29 insertions(+) create mode 100644 function_app.py create mode 100644 host.json create mode 100644 local.settings.json diff --git a/function_app.py b/function_app.py new file mode 100644 index 00000000..d23cfaf0 --- /dev/null +++ b/function_app.py @@ -0,0 +1,14 @@ +import azure.functions as func +from app import create_app + +funcapp = func.FunctionApp() +flaskapp = create_app() + + +@funcapp.route( + route="{*route}", + auth_level=func.AuthLevel.ANONYMOUS, + methods=[func.HttpMethod.GET, func.HttpMethod.POST], +) +def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: + return func.WsgiMiddleware(flaskapp.wsgi_app).handle(req, context) diff --git a/host.json b/host.json new file mode 100644 index 00000000..d7af4b62 --- /dev/null +++ b/host.json @@ -0,0 +1,8 @@ +{ + "version": "2.0", + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[4.*, 5.0.0)" + } +} + diff --git a/local.settings.json b/local.settings.json new file mode 100644 index 00000000..614f2f1c --- /dev/null +++ b/local.settings.json @@ -0,0 +1,7 @@ +{ + "IsEncrypted": false, + "Values": { + "FUNCTIONS_WORKER_RUNTIME": "python", + "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" + } +}