Share via

App Service Application error

Application error 1 Reputation point
2020-10-21T09:53:27.567+00:00

Dear Microsoft,

I had created Rest API with Python+Flask App Service,I tried running in local virtual environment with http://0.0.0.0:5000.It ws perfectly working,but when I deployed in cloud,it was not successful,where I was getting Application error,there is a file requirements.txt to install the libraries.In deployment log it was showing all the libraries were installed, but in the log stream it was displaying errors Container not started.I had tried all of the options mentioned in the documentations but nothing worke33898-logs.txtd out, Could you please help me in this regard.

Thanks & Regards,
Venkat

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Ajay Kumar N 28,261 Reputation points Microsoft Employee Moderator
    2020-10-21T20:43:06.417+00:00

    @Application error , Thanks for posting a detailed question, Venkat.

    I notice that this time, your webapps shows as Stopped and previously sometime back showed Application error’. With the details you have shared, I performed some initial investigations and suggest you try these steps:

    I see that you’re running on Linux App Service Plan Free tier and Always on is not enabled on your WebApp.

    1. By default, web apps are unloaded if they are idle for some period of time. This lets the system conserve resources. In Basic or Standard mode, you can enable Always On to keep the app loaded all the time. I have also noticed high CPU usage and timeout error on your WebApp.
      So, I suggest you scale-up your App service Plan and then enable Always on feature.

    2.The automatic port detection detects the port (port 80 is the default), App service will attempt to detect which port to bind to your container, but you can also use the WEBSITES_PORT app setting and configure it with a value for the port you want to bind to your container.

    For your custom container use the WEBSITES_PORT app setting.

    For a different port - Use the EXPOSE instruction in your Dockerfile to expose the appropriate port (E.g 5000) and use the WEBSITES_PORT app setting on Azure with a value of "5000" to expose that port.

    3.For the Flask, App Service looks for a file named application.py or app.py and starts Gunicorn as follows:

    if application.py  ->   gunicorn --bind=0.0.0.0 --timeout 600 application:app  
    If app.py  ->              gunicorn --bind=0.0.0.0 --timeout 600 app:app  
    

    You can control the container's startup behavior by providing either a custom startup command or multiple commands in a startup command file.

    Azure portal: select the app's Configuration page, then select General settings. In the Startup Command field, place either the full text of your startup command or the name of your startup command file. Then select Save to apply the changes.

    If the issue still persists, try step -4.

    4.You can configure the amount of time the platform will wait before it restarts your container. To do so, set the WEBSITES_CONTAINER_START_TIME_LIMIT app setting to the value you want. The default value is 230 seconds, and the maximum value is 1800 seconds.
    To do this, from the Azure Portal> Navigate to your WebApp > Under Settings blade > Go to “Configuration” > Add the above app setting with ‘Name’ with 1800 as ‘Value’ .

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.