Linux App Service stops responding

Neal Hollingsworth 1 Reputation point
2020-08-22T15:14:46.7+00:00

I've been working on a Flask app (Python 3.8) on Linux. It is currently running on a B1 instance with no other apps. The instance will start without issue, and respond reasonably quickly, but after a short time it appears to stop responding. The app is set to 'Always on', but the log stream shows nothing (no errors, but also no http requests). Some times the app appears to start again and respond as expected, but only after multiple minutes of delay. There doesn't appear to be excessive CPU or memory usage. Am I missing a setting that causes the service to stop? Is there a way to get better logs from the app server (i.e. is it possible requests are not making it to the log stream? Errors from gunicorn? Possible errors from the container?) I'm drawing a bit of a blank on this because there are no apparent errors. Thanks for any help or hints where to look.

Azure Web Apps
Azure Web Apps
A feature of Azure App Service used to create and deploy scalable, mission-critical web apps.
4,315 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 11,101 Reputation points Microsoft Employee
    2020-08-24T08:25:58.503+00:00

    Thanks for asking question! You can access the diagnostic logs by accessing the console logs generated from inside the container.
    First, turn on container logging by running the below command in the Azure Cloud Shell

    az webapp log config --name <app-name> --resource-group myResourceGroup --docker-container-logging filesystem

    You can now see the log stream by running below command.

    az webapp log tail --name <app-name> --resource-group myResourceGroup

    You may also investigate the log files from the browser link: https://<app-name>.scm.azurewebsites.net/api/logs/docker

    To add to this:

    • If the browser has timed out waiting for a response from App Service, this indicates that App Service started the Gunicorn server, but
      the arguments that specify the app code are incorrect.
    • Check that your app is structured as App Service expects for Django or Flask, or use a custom startup command.
    • try capturing a network trace to help identify if responses from the endpoint are slower than expected.
    • If high number of processes are waiting for CPU consider scaling up to a higher SKU.

    You may refer to this official doc link: https://learn.microsoft.com/en-us/azure/app-service/configure-language-python

    Let me know if issue persists.