from __future__ import annotations import azure.functions as func from starlette.applications import Starlette from starlette.routing import Mount from ai_search_agent.api import create_app _fastapi = create_app() # Azure Functions delivers the full path including /api/ prefix to the ASGI app. # Mount FastAPI under /api so that /api/health -> FastAPI /health, etc. _root = Starlette(routes=[Mount("/api", app=_fastapi)]) app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) @app.route(route="{*route}") async def asgi_handler(req: func.HttpRequest) -> func.HttpResponse: return await func.AsgiMiddleware(_root).handle_async(req)