-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Multiple ASGI functions with different names #1330
Comments
@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:
"""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
{
"version": "2.0",
"extensions": {
"http": {
"routePrefix": ""
}
}
} |
This has been addressed in Azure/azure-functions-python-library#216 and will be available in the latest library version. |
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
The text was updated successfully, but these errors were encountered: