Azure WebSites doesn't return response body fo

2019-08-09 16:42发布

问题:

I have the following configuration: Python TornadoWeb application deployed on Azure Web Sites. The application is actually REST API that returns JSON back. However... everything works fine if the response code is 200 but if the response code is anything like 50x or 40x the response doesn't contain any body (although there should still be JSON body with error details). Testing the same code locally directly to Tornado or via NGiNX works. Apparently, IIS filters the body but not really sure what settings to change in order to avoid this. Any ideas?

回答1:

Please try to refer to the sections WSGI Handler and Web.config of the doc "Configuring Python with Azure App Service Web Apps" to configure and code for your Python Tornado webapp as Running Tornado apps on WSGI servers.

If you created a Azure WebApp for Python, you can do the steps below.

  1. Create a web.config file in the Kudu path wwwroot, then copy the configuration content from the section Web.config.
  2. Create a app.py file in the Kudu path wwwroot, then code as the section WSGI Handler.
  3. Try to start and access the webapp.
  4. Recode the webapp using Tornado.


回答2:

You will probably need to create a web.config and set the customErrors element appropriately. These are the options. The web.config will need to reside in the root of ur deployed folder structure. Generally speaking one should not expose every single internal error detail with stack trace to users because they probably will not be able to understand it all and it will also give much information about ur system to a potential attacker. That is why I prefer short error messages as http response and the rest gets logged somewhere for later analysis.