/ azure

Debug Python Applications in Azure Web Apps

After creating a Azure Web app using Python, you may end-up getting below 500 error at some point of your application development process.This Blog describes how to enable logs for a Python Web APP on Azure.

The page cannot be displayed because an internal server error has occurred.

If you have worked earlier on Azure Web app, General tendency would be to look at LogFiles folder in kudu console https://Your_Website.scm.azurewebsites.net but that won't provide you much info about python application issue.

To overcome this, Please follow below set of instructions to receive application logs

  • Navigate to your new azure portal and click on settings in your Web app.
  • Click on Application Settings in Settings Tab
  • Enter Below Key/Value pair under App Settings in Application Settings Tab.
Key : WSGI_LOG
Value : D:\home\site\wwwroot\logs.txt    (Enter your choice of file name here)

Azure App Setting

  • Now you should be able to see logs.txt file in wwwroot folder as mentioned in above step

Python Output Logs

Troubleshoot :

If you still haven't found that logs.txt file, check if ptvs_virtualenv_proxy.py file is similar to below link content. https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/#virtual-environment-proxy

Find more details on using Python in Azure Web Apps at below links :

Prashanth Madi

Prashanth Madi

I'm a programmer & Tech enthusiast. I work for OpenSource Support Team at Microsoft, but this blog, its content & opinions are my own. I blog about tech, gadgets, code, where we're going & we've been.

Read More