An Azure service that provides an event-driven serverless compute platform.
Hi @Akash Kumar [C],
Thanks for reaching out to Microsoft Q&A.
Deploying a Django application to an Azure Function App on Linux can be quite complex and prone to issues especially when using the Python v2 programming model because Django is a full-fledged web framework that relies on a WSGI/ASGI lifecycle, whereas Azure Functions is built around small, event-driven/serverless functions, not full web apps. That mismatch is usually the root of most of the errors.
In Python v1 model, you can somewhat work around this by using an HTTP trigger with __init__.py and function.json, installing Django via requirements.txt, initializing it with get_wsgi_application(), and routing all requests through a single function though this approach is still limited.
With the newer Python v2 model, which uses a decorator-based approach function_app.py, integrating Django becomes even more restrictive; you would need to manually set the DJANGO_SETTINGS_MODULE, define a wildcard route, and attempt to handle requests, but issues with routing, middleware, and static files are common.
Because of these limitations, the recommended and more stable solution is to deploy Django using Azure App Service, where you can simply configure your app with a requirements.txt, set the startup command E.g., gunicorn myproject.wsgi, manage environment variables, and deploy it.
Hosting a Django site requires a few extra steps if you are using Python V1(Very limited).
- In your Function App’s Configuration, set SCM_DO_BUILD_DURING_DEPLOYMENT = true
- Install and wire up WSGI middleware
- Add to requirements.txt:
azure-functions
azure-functions-wsgi
Django
- In your Function's
__init__.py, expose Django via WSGI:
import azure.functions as func
from your_project.wsgi import application
def main(req: func.HttpRequest) -> func.HttpResponse:
return func.HttpResponse("Django not fully supported here")
Hope this helps!
If the resolution was helpful, kindly take a moment to click on and click on Yes for was this answer helpful. And, if you have any further query do let us know.