Azure-Samples / fastapi-on-azure-functions

A sample to run a FastAPI app on Azure Functions
MIT License
89 stars 69 forks source link

fastapi background tasks do not work on azure function apps #33

Open warreee opened 4 months ago

warreee commented 4 months ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

I added background tasks as described in https://fastapi.tiangolo.com/tutorial/background-tasks/. You can see this in my fork of this repo: https://github.com/warreee/fastapi-on-azure-functions-background-tasks. When running locally or in Azure will see that a response is not returned immediately but only after 5 seconds (the delay set in the background task).

Any log messages given by the failure

Expected/desired behavior

I expect the function app to give an immediate response while still finishing the background task afterwards.

OS and Version?

MacOs Sonoma

Versions

Function runtime: 4.33.2.2 Python: 3.11

Mention any other details that might be useful


Thanks! We'll be in touch soon.