diff --git a/README.md b/README.md index 538ad0f..772ffe5 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,6 @@ The `requirements.txt` file has an additional dependency of the `fastapi` and `n ``` azure-functions fastapi -nest_asyncio ``` @@ -84,11 +83,8 @@ In that same folder, the `__init__.py` file uses `AsgiMiddleware` to redirect in ```python import logging import azure.functions as func -import nest_asyncio from FastAPIApp import app # Main API application -nest_asyncio.apply() - @app.get("/sample") async def index(): @@ -105,7 +101,7 @@ async def get_name(name: str): async def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: """Each request is redirected to the ASGI handler.""" - return func.AsgiMiddleware(app).handle(req, context) + return await func.AsgiMiddleware(app).handle_async(req, context) ``` ## Running the sample diff --git a/WrapperFunction/__init__.py b/WrapperFunction/__init__.py index 3249d90..784892c 100644 --- a/WrapperFunction/__init__.py +++ b/WrapperFunction/__init__.py @@ -1,10 +1,7 @@ import logging import azure.functions as func -import nest_asyncio from FastAPIApp import app # Main API application -nest_asyncio.apply() - @app.get("/sample") async def index(): @@ -21,4 +18,4 @@ async def get_name(name: str): async def main(req: func.HttpRequest, context: func.Context) -> func.HttpResponse: - return func.AsgiMiddleware(app).handle(req, context) + return await func.AsgiMiddleware(app).handle_async(req, context) diff --git a/requirements.txt b/requirements.txt index d4f3ba0..d56fc99 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,3 @@ azure-functions fastapi -nest_asyncio \ No newline at end of file