Open michael-wimmer-mw opened 8 months ago
The same happens to me. Furthermore, in Insights, functions cannot be distinguished as they all have the same name.
@MichaelWimmerMaibornWolff, thanks for raising the issue. Unfortunately, it is not supported by our current python function runtime architecture, but we are working on new features that can resolve this problem. Will keep you updated.
This works if you want multiple endpoints:
function_app.py
"""Main app"""
import azure.functions as func
from fastapi import FastAPI
fast_app_1 = FastAPI(root_path="/1")
fast_app_2 = FastAPI(root_path="/2")
@fast_app_1.get("/hello/{name}")
@fast_app_2.get("/hello/{name}")
async def get_name(name: str):
return {
"name": name,
}
app = func.FunctionApp()
# Azure Functions v2 HTTP trigger decorator
@app.function_name("backend-api1")
@app.route(route="1/{*route}", auth_level=func.AuthLevel.ANONYMOUS)
async def backend_api(req: func.HttpRequest) -> func.HttpResponse:
return await func.AsgiMiddleware(fast_app_1).handle_async(req) # pragma: no cover
@app.function_name("backend-api2")
@app.route(route="2/{*route}", auth_level=func.AuthLevel.ANONYMOUS)
async def backend_api(req: func.HttpRequest) -> func.HttpResponse:
return await func.AsgiMiddleware(fast_app_2).handle_async(req) # pragma: no cover
host.json
{
"version": "2.0",
"extensions": {
"http": {
"routePrefix": ""
}
}
}
We want to deploy multiple ASGI services (FastAPI) using this approach: https://learn.microsoft.com/en-us/samples/azure-samples/fastapi-on-azure-functions/azure-functions-python-create-fastapi-app/ Currently, the functions are always called http_app_func. That means that if we deploy one service it overwrites the one which was deployed previously. Is there a way to customize the name of the function or any other possibility to have multiple ASGI services deployed in one function app?
Thanks in advance, Michael