500 Server Error on Django on App Service when Debug=False

ehoke 56 Reputation points
2021-06-23T21:03:40.793+00:00

When I set Debug=False in my django app deployed to Azure App Service I get a 500 Server Error whenever I try to navigate to any of API pages or the admin panel. The application still works fine, I have a React front end that is still connected to the API however I cannot access API pages directly. Looking at SE I found that this was a common problem for Heroku users but not for Azure and I made some adjustments to my code that unfortunately didn't really help. I have two questions:

  1. Has anyone run into this issue before on Azure?
  2. One of the solutions that was recommended for Heroku users was to comment out the following line in production.py
    STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
    I am a bit hesitant to do this since I don't want to mess up the build sequence, but has anyone tried this method and gotten it to work without ruining their deployment?
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,914 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 22,416 Reputation points Microsoft Employee
    2021-07-05T19:38:02.02+00:00

    Posting our offline discussion to benefit the community.

    Using the settings should not affect the build sequence if you are using Oryx to build the app, this also depends on app service configurations and deployment method.
    Based on the doc of WhiteNoise, removing the line will disable WhiteNoise module used to serve static files, performance might suffer as WhiteNoise is used to enhance static content performance on Python.

    https://github.com/projectkudu/kudu/wiki/Configurable-settings#enabledisable-build-actions
    SCM_DO_BUILD_DURING_DEPLOYMENT=true – With this setting set to true - Kudu will execute build steps on your site during deployment.

    Oryx attempts to build and run Django apps appropriately – Best practices tips for Django apps.
    https://github.com/microsoft/Oryx/wiki/Django-Tips

    Thanks again for your patience and cooperation, @ehoke