Python flask web app crashes when trying to access Cosmos DB RRS feed

  • Question

  • Hello, I have created Azure Cosmos DB with MongoDB API and now want to access it from python flask web app. So I did following:

    1. Created service plan for web app: az appservice plan create --name <PlanName> --resource-group <ResourceGroupName> --sku FREE

    2. Created app: az webapp create --resource-group <ResourceGroupName> --plan <PlanName> --name <AppName> --runtime "python|2.7" --deployment-local-git

    3. Cloned demo app (https://github.com/Azure-Samples/python-docs-hello-world)

    4. Added pymongo to requirements.txt and created client: client = MongoClient(<ClientConnectionString>)

    Now, the application is not running healthily (or not running at all), but if I don't create client, everything is fine, so the reason behind it is exactly with client initialization. What might be the problem? The web.2.7.config I use is exactly same like in repository. I asked question on stackoverflow and it worked for while but now doesn't.

    Wednesday, March 7, 2018 2:02 PM

All replies

  • Could you share the complete error message or screenshot of the issue?

    Do click on "Mark as Answer" and “Vote as Helpful” on the post that helps you, this can be beneficial to other community members.

    Wednesday, March 7, 2018 7:00 PM
  • Ashok, the only error I see is error 500 on python webapp's front page. I tried to launch app from kudu console - in this case I had to install all requirements manually - app works fine but I still see error in browser and I don't know how that happens. I tried approach described here:


    and it worked for a while but now doesn't :-(

    Friday, March 9, 2018 1:59 PM
  • There could be different root causes for 500 error messages. Sub-status codes will help you understand the issue better.

    I would suggest you Enable diagnostics logging for web apps in Azure App Service in case if you haven’t enabled earlier and also check Web Server Logs for getting to the root cause of this issue.

    Do click on "Mark as Answer" and “Vote as Helpful” on the post that helps you, this can be beneficial to other community members.

    Sunday, March 11, 2018 4:24 PM
  • Ashok,

    I enabled diagnostics as was suggested in first article and can see error is 500.0: "Internal Server Error: The page cannot be displayed because an internal server error has occurred.".

    From logs:

    - Most likely causes

    a) IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.

    b) IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.

    c) IIS was not able to process configuration for the Web site or application.

    d) The authenticated user does not have permission to use this DLL.

    e) The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.

    - Things you can try

    a) Ensure that the NTFS permissions for the web.config file are correct and allow access to the Web server's machine account.

    b) Check the event logs to see if any additional information was logged.

    c) Verify the permissions for the DLL.

    d) Install the .NET Extensibility feature if the request is mapped to a managed handler.

    e) Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click <a href="http://go.microsoft.com/fwlink/?LinkID=66439">here</a>

    Monday, March 12, 2018 9:57 AM
  • This would require further troubleshooting to find out the root cause. Follow the link to create Azure Technical Support Request. It would also require your subscription details that are best done on the technical support channel and not on the public forums.

    Do click on "Mark as Answer" and “Vote as Helpful” on the post that helps you, this can be beneficial to other community members.

    Monday, March 12, 2018 7:45 PM