Share via

Python Django application can be deployed in Function app with Linux OS

Akash Kumar [C] 20 Reputation points
2026-03-27T13:49:21+00:00

I am trying to deploy Python Django application in Function app with Linux OS. But its throwing me lots of issues and errors

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.

0 comments No comments

Answer accepted by question author
  1. Pravallika KV 12,575 Reputation points Microsoft External Staff Moderator
    2026-03-27T15:57:13.9666667+00:00

    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).

    1. In your Function App’s Configuration, set SCM_DO_BUILD_DURING_DEPLOYMENT = true
    2. 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 User's imageand click on Yes for was this answer helpful. And, if you have any further query do let us know.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Q&A Assist
    2026-03-27T13:49:33.92+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    A Python Django application should not be deployed directly as an Azure Function App. Azure Functions is optimized for event-driven, serverless functions, not for hosting full web frameworks like Django.

    For a Django web application on Linux, use Azure App Service for Linux instead of Function App. The recommended approach is:

    1. Create an App Service (Linux) for Python.
    2. Structure the Django project as expected by App Service (manage.py and the Django project in the root, with a proper requirements.txt).
    3. Deploy the app code to App Service and let Oryx build and install dependencies by setting the SCM_DO_BUILD_DURING_DEPLOYMENT app setting to 1 if needed.
    4. If the default app appears or the app fails to start, use the troubleshooting steps:
      • Use Diagnose and solve problemsAvailability and Performance to check Application Logs, Container Crash, and Container Issues.
      • Use SSH to confirm the app files and requirements.txt are under /site/wwwroot.
      • Ensure the app is structured as App Service expects for Django or configure a custom startup command.

    If the goal is specifically to use Azure Functions (for background tasks, APIs, or event handlers) alongside Django, host Django in App Service and use Azure Functions separately for serverless workloads, following the Python Functions guidance and troubleshooting for ModuleNotFoundError and build issues (for example, using SCM_DO_BUILD_DURING_DEPLOYMENT and ENABLE_ORYX_BUILD when publishing via zipdeploy).


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.