Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
@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.
- 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 Onto 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 enableAlways onfeature.
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’ .