azure-functions-python-library icon indicating copy to clipboard operation
azure-functions-python-library copied to clipboard

Can't change default function name while using FastAPI

Open ronaldo-omg opened this issue 2 years ago • 6 comments

I've been trying to set a custom name while using FastAPI and couldn't find the proper way. It always deploys my function with the name "http_app_func," making deploying multiple functions to the same app impossible.

Has anyone been successful with this task?

This is the syntax I thought it would work:

app = func.AsgiFunctionApp(app=fastapi_app, http_auth_level=func.AuthLevel.FUNCTION).function_name(name="HttpTest")

ronaldo-omg avatar Dec 05 '23 20:12 ronaldo-omg

Hi! I think this issue is related to this:

https://github.com/Azure/azure-functions-docker/issues/1033

In short, the AsgiFunctionApp does not have the mix-in from BindingApi and SettingsApi, and I think it's the latter that makes this fail.

Does anyone have a good explanation why these two are missing?

mortendaehli avatar Feb 05 '24 08:02 mortendaehli

Hi! @ronaldo-omg ! Were you able to find a workaround here?

sepira avatar Mar 06 '24 00:03 sepira

I'm interested in this as well. There's a similar discussion going on here:

https://github.com/Azure/azure-functions-python-worker/issues/1284

DCMattyG avatar Apr 25 '24 04:04 DCMattyG

For the time being I commented out both calls to "self._add_http_app" under the AsgiFunctionApp and WsgiFunctionApp classes in function_app.py.

The amount of bugs I came across just trying to get started with Azure functions is unbelievable. This is the 6th or 7th bug I've encountered.

seidnerj avatar May 02 '24 16:05 seidnerj

I think in previous versions of the azure-functions python package you could do it with the set_function_name method for each function in the app. That seems to have been deprecated now but this article outlines another way to do it using add_setting.

https://medium.com/mesh-ai-technology-and-engineering/how-to-host-fastapi-in-an-azure-function-and-thre-7f7bbb924344

himat-mesh-ai avatar Aug 23 '24 09:08 himat-mesh-ai

I think in previous versions of the azure-functions python package you could do it with the set_function_name method for each function in the app. That seems to have been deprecated now but this article outlines another way to do it using add_setting.

https://medium.com/mesh-ai-technology-and-engineering/how-to-host-fastapi-in-an-azure-function-and-thre-7f7bbb924344

Thanks this worked like gangbusters! I still have an awful time deploying fastapi as Azure Functions

rudrashishbose avatar May 13 '25 07:05 rudrashishbose