简体   繁体   English

Azure Web App Service“容器不健康”错误,强制容器每 15 分钟重新启动一次

[英]Azure Web App Service "container is unhealthy" error forcing container restart every 15min

I have a dot net core 3.1 app running in an Azure Web App environment (Linux).我有一个在 Azure Web App 环境 (Linux) 中运行的 dot net core 3.1 应用程序。 The app is running fine in local environment/debug.该应用程序在本地环境/调试中运行良好。 When publishing to Azure, the app runs, but in the Applictions logs, I see the container is restarting every ~15min due to unhealthy container message.发布到 Azure 时,应用程序运行,但在应用程序日志中,由于容器消息不正常,我看到容器每隔约 15 分钟重新启动一次。 The memory and processor load is well below 50% and there is no special load on the application.内存和处理器负载远低于 50%,应用程序没有特殊负载。

I dont know why it shows "unhealthy" in the logs and restarts the container so frequently.我不知道为什么它在日志中显示“不健康”并如此频繁地重新启动容器。 Is there anything missing in the configuration settings?配置设置中是否缺少任何内容?

Why does the container restart frequently and where to look for more error specific information to debug this issue?为什么容器会频繁重启,在哪里寻找更多的错误特定信息来调试这个问题?

Any hint is welcome.欢迎任何提示。

Application Logs:应用程序日志:

2020-10-06T08:08:57.693Z INFO  - Starting container for site
2020-10-06T08:08:57.693Z INFO  - docker run -d -p 5159:8080 --name wttcycleswebapp_0_8c7e9ba1 -e WEBSITE_SITE_NAME=WTTCyclesWebApp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=wttcycleswebapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=92c475eedd41771f9c6f8d7f8c52ad11b610d1d082a92269eb132b8b216a0d8d -e HTTP_LOGGING_ENABLED=1 appsvc/dotnetcore:3.1-latest_20200717.2 dotnet Cycles.dll 

2020-10-06T08:08:58.845Z INFO  - Initiating warmup request to container wttcycleswebapp_0_8c7e9ba1 for site wttcycleswebapp
2020-10-06T08:09:04.094Z INFO  - Container wttcycleswebapp_0_8c7e9ba1 for site wttcycleswebapp initialized successfully and is ready to serve requests.
2020-10-06T08:24:34.102Z ERROR - Container for wttcycleswebapp_0_8c7e9ba1 site wttcycleswebapp is unhealthy, Stopping site.
2020-10-06T08:24:34.102Z INFO  - Stopping site wttcycleswebapp because it is not healthy.
2020-10-06T08:27:15.247Z INFO  - Starting container for site
2020-10-06T08:27:15.248Z INFO  - docker run -d -p 6236:8080 --name wttcycleswebapp_0_6391dc4a -e WEBSITE_SITE_NAME=WTTCyclesWebApp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=wttcycleswebapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=92c475eedd41771f9c6f8d7f8c52ad11b610d1d082a92269eb132b8b216a0d8d -e HTTP_LOGGING_ENABLED=1 appsvc/dotnetcore:3.1-latest_20200717.2 dotnet Cycles.dll 

2020-10-06T08:27:16.384Z INFO  - Initiating warmup request to container wttcycleswebapp_0_6391dc4a for site wttcycleswebapp
2020-10-06T08:27:20.657Z INFO  - Container wttcycleswebapp_0_6391dc4a for site wttcycleswebapp initialized successfully and is ready to serve requests.
2020-10-06T08:36:35.799Z ERROR - Container for wttcycleswebapp_0_6391dc4a site wttcycleswebapp is unhealthy, Stopping site.
2020-10-06T08:36:35.799Z INFO  - Stopping site wttcycleswebapp because it is not healthy.
2020-10-06T08:36:38.668Z INFO  - Starting container for site
2020-10-06T08:36:38.669Z INFO  - docker run -d -p 3648:8080 --name wttcycleswebapp_0_6ad6dbd7 -e WEBSITE_SITE_NAME=WTTCyclesWebApp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=wttcycleswebapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=92c475eedd41771f9c6f8d7f8c52ad11b610d1d082a92269eb132b8b216a0d8d -e HTTP_LOGGING_ENABLED=1 appsvc/dotnetcore:3.1-latest_20200717.2 dotnet Cycles.dll 

2020-10-06T08:36:39.633Z INFO  - Initiating warmup request to container wttcycleswebapp_0_6ad6dbd7 for site wttcycleswebapp
2020-10-06T08:36:43.884Z INFO  - Container wttcycleswebapp_0_6ad6dbd7 for site wttcycleswebapp initialized successfully and is ready to serve requests.
2020-10-06T08:51:38.900Z ERROR - Container for wttcycleswebapp_0_6ad6dbd7 site wttcycleswebapp is unhealthy, Stopping site.
2020-10-06T08:51:38.901Z INFO  - Stopping site wttcycleswebapp because it is not healthy.
2020-10-06T08:51:39.775Z INFO  - Starting container for site
2020-10-06T08:51:39.776Z INFO  - docker run -d -p 3002:8080 --name wttcycleswebapp_0_f59f6020 -e WEBSITE_SITE_NAME=WTTCyclesWebApp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=wttcycleswebapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=92c475eedd41771f9c6f8d7f8c52ad11b610d1d082a92269eb132b8b216a0d8d -e HTTP_LOGGING_ENABLED=1 appsvc/dotnetcore:3.1-latest_20200717.2 dotnet Cycles.dll 

2020-10-06T08:51:40.854Z INFO  - Initiating warmup request to container wttcycleswebapp_0_f59f6020 for site wttcycleswebapp
2020-10-06T08:51:45.135Z INFO  - Container wttcycleswebapp_0_f59f6020 for site wttcycleswebapp initialized successfully and is ready to serve requests.
2020-10-06T09:23:50.153Z ERROR - Container for wttcycleswebapp_0_f59f6020 site wttcycleswebapp is unhealthy, Stopping site.
2020-10-06T09:23:50.154Z INFO  - Stopping site wttcycleswebapp because it is not healthy.
2020-10-06T09:23:50.958Z INFO  - Starting container for site
2020-10-06T09:23:50.959Z INFO  - docker run -d -p 3270:8080 --name wttcycleswebapp_0_0c8ce05e -e WEBSITE_SITE_NAME=WTTCyclesWebApp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=wttcycleswebapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=92c475eedd41771f9c6f8d7f8c52ad11b610d1d082a92269eb132b8b216a0d8d -e HTTP_LOGGING_ENABLED=1 appsvc/dotnetcore:3.1-latest_20200717.2 dotnet Cycles.dll 

2020-10-06T09:24:01.308Z INFO  - Initiating warmup request to container wttcycleswebapp_0_0c8ce05e for site wttcycleswebapp
2020-10-06T09:24:01.600Z INFO  - Container wttcycleswebapp_0_0c8ce05e for site wttcycleswebapp initialized successfully and is ready to serve requests.
2020-10-06T11:00:33.648Z INFO  - Starting container for site
2020-10-06T11:00:33.649Z INFO  - docker run -d -p 4757:8080 --name wttcycleswebapp_2_de12fb53 -e WEBSITE_SITE_NAME=WTTCyclesWebApp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=wttcycleswebapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=92c475eedd41771f9c6f8d7f8c52ad11b610d1d082a92269eb132b8b216a0d8d -e HTTP_LOGGING_ENABLED=1 appsvc/dotnetcore:3.1-latest_20200717.2 dotnet Cycles.dll 

2020-10-06T11:00:35.792Z INFO  - Initiating warmup request to container wttcycleswebapp_2_de12fb53 for site wttcycleswebapp
2020-10-06T11:00:42.307Z INFO  - Container wttcycleswebapp_2_de12fb53 for site wttcycleswebapp initialized successfully and is ready to serve requests.
2020-10-06T11:16:17.316Z ERROR - Container for wttcycleswebapp_2_de12fb53 site wttcycleswebapp is unhealthy, Stopping site.
2020-10-06T11:16:17.316Z INFO  - Stopping site wttcycleswebapp because it is not healthy.
2020-10-06T11:16:24.769Z INFO  - Starting container for site
2020-10-06T11:16:24.769Z INFO  - docker run -d -p 1185:8080 --name wttcycleswebapp_0_3904d3bf -e WEBSITE_SITE_NAME=WTTCyclesWebApp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=wttcycleswebapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=92c475eedd41771f9c6f8d7f8c52ad11b610d1d082a92269eb132b8b216a0d8d -e HTTP_LOGGING_ENABLED=1 appsvc/dotnetcore:3.1-latest_20200717.2 dotnet Cycles.dll 

2020-10-06T11:16:25.662Z INFO  - Initiating warmup request to container wttcycleswebapp_0_3904d3bf for site wttcycleswebapp
2020-10-06T11:16:36.943Z INFO  - Container wttcycleswebapp_0_3904d3bf for site wttcycleswebapp initialized successfully and is ready to serve requests.
2020-10-06T11:31:56.959Z ERROR - Container for wttcycleswebapp_0_3904d3bf site wttcycleswebapp is unhealthy, Stopping site.
2020-10-06T11:31:56.959Z INFO  - Stopping site wttcycleswebapp because it is not healthy.
2020-10-06T11:31:58.658Z INFO  - Starting container for site
2020-10-06T11:31:58.659Z INFO  - docker run -d -p 2576:8080 --name wttcycleswebapp_0_590a51f3 -e WEBSITE_SITE_NAME=WTTCyclesWebApp -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=wttcycleswebapp.azurewebsites.net -e WEBSITE_INSTANCE_ID=92c475eedd41771f9c6f8d7f8c52ad11b610d1d082a92269eb132b8b216a0d8d -e HTTP_LOGGING_ENABLED=1 appsvc/dotnetcore:3.1-latest_20200717.2 dotnet Cycles.dll 

2020-10-06T11:31:59.684Z INFO  - Initiating warmup request to container wttcycleswebapp_0_590a51f3 for site wttcycleswebapp
2020-10-06T11:32:03.912Z INFO  - Container wttcycleswebapp_0_590a51f3 for site wttcycleswebapp initialized successfully and is ready to serve requests.

In addition, I can see in the "container crash" log:另外,我可以在“容器崩溃”日志中看到:

Container exited unexpectedly: last 10 seconds logs [
2020-10-06T11:16:14.928728537Z Could not open output /home/logs/dumps/coredump.f7d267b6a38a.28.1601982035: No such file or directory
2020-10-06T11:16:14.931442136Z Writing minidump with heap to file /home/logs/dumps/coredump.f7d267b6a38a.28.1601982035
2020-10-06T11:16:15.118711399Z /opt/startup/startup.sh: line 10:    28 Aborted                 (core dumped) dotnet Cycles.dll
]

It looks like your application is crashing when trying to write logs on the file system.尝试在文件系统上写入日志时,您的应用程序似乎崩溃了。 This could be the cause of failure if your logs are written to the disk or rotated every 15 minutes.如果您的日志被写入磁盘或每 15 分钟轮换一次,这可能是失败的原因。 As a good practise, it's probably better to redirect the logs to standard console output instead of writing them to the file system.作为一种好的做法,最好将日志重定向到标准控制台输出,而不是将它们写入文件系统。

Another potential explanation could be a permission issue on the log location另一个可能的解释可能是日志位置的权限问题

Agree with totor that it is related to the log files.同意 totor 它与日志文件有关。

That it works locally but not in Azure gives a clue to what may be the root cause.它在本地工作但在 Azure 中不起作用,这为可能是根本原因提供了线索。

It may be that you need to enable container logs.您可能需要启用容器日志。

App Service -> Monitoring -> App Service logs : Then turn on file system logging应用服务 -> 监控 -> 应用服务日志:然后打开文件系统日志记录

Your problem could be related with service quotas .您的问题可能与服务配额有关。

Depending of your app service plan, your application can be subject to certain limits on the resources it can use.根据您的应用程序服务计划,您的应用程序可能会受到其可以使用的资源的某些限制。

Free and shared apps are more constrained, but even with other service plans the filesystem quota always applies.免费和共享应用程序受到更多限制,但即使使用其他服务计划,文件系统配额也始终适用。

As the documentation indicates, if the app memory quota is exceeded, the app is stopped temporarily;如文档所示,如果超过应用程序内存配额,应用程序将暂时停止; if the filesystem quota is exceeded, any write operation fails, even writes to logs.如果超过文件系统配额,任何写入操作都会失败,甚至写入日志。

Either of these two reasons or something else related to quotas could be the source of your problem.这两个原因中的任何一个或与配额相关的其他原因都可能是您问题的根源。

You can check the quotas and limits of every app service plan here .您可以在此处查看每个应用服务计划的配额和限制。

You can monitor your app service quotas metrics from the option App Service Plan > Quotas in your app service detail page on Azure portal.您可以从 Azure 门户上应用服务详细信息页面中的应用App Service Plan > Quotas选项监控应用服务配额指标。

It seems your App Service has a Health Check configured and it is failing, causing Azure to restart it periodically.您的应用服务似乎配置了运行状况检查,但它失败了,导致 Azure 定期重新启动它。

On your App Service's configuration, go to Monitoring > Health check and check if it is enabled.在您的应用服务配置中,转到“ Monitoring > Health check ”并检查它是否已启用。 If it is, try disabling it:如果是,请尝试禁用它:

在此处输入图像描述

Remember to click Save记得点击保存

In my case, Azure still restarted the App Service at least once after I disabled the health checks.就我而言,在我禁用运行状况检查后,Azure 仍然至少重新启动了一次应用服务。 To be on the safe side, I recommend that you stop and start the App Service after disabling the health check.为了安全起见,我建议您在禁用健康检查后停止并启动应用服务。

Validate your health check path exists and works.验证您的健康检查路径是否存在并且有效。 As it says in the image below,如下图所示,

Health check configuration changes will restart your app.健康检查配置更改将重新启动您的应用。 To minimize impact to production apps, we recommend setting it up on a staging slot and swapping it into production.为了尽量减少对生产应用程序的影响,我们建议将其设置在暂存槽上并将其交换到生产环境中。

An invalid health check will restart your app.无效的运行状况检查将重新启动您的应用。 在此处输入图像描述

My problem was an invalid health Path .我的问题是无效的健康Path My application handles /health , but we previously defined Path as /health/ which apparently is not the same.我的应用程序处理/health ,但我们之前将Path定义为/health/ ,这显然不一样。

Note that disabling your health check won't affect slot swapping.请注意,禁用运行状况检查不会影响插槽交换。

Had this same issue when I deployed an Azure Web App.当我部署 Azure Web 应用程序时遇到了同样的问题。

I was getting the error:我收到了错误:

Your app is unhealthy.您的应用程序运行状况不佳。 Click here for details点击这里了解详情

在此处输入图像描述

Here's how I fixed it :这是我修复它的方法

The issue was that since my Application did not have a defined path for Health Check, I wanted to use the homepage/root path as the Health Check Path.问题是,由于我的应用程序没有定义健康检查路径,我想使用主页/根路径作为健康检查路径。

For this, I was specifying the Health Check Path as the URL of App Service ( api.mywebsite.com ) instead of the root path ( / )为此,我将运行状况检查路径指定为应用服务 ( api.mywebsite.com ) 的 URL,而不是根路径 ( / )

Changing the Health Check Path from the URL of App Service ( api.mywebsite.com ) to the root path ( / ) solved the issue for me.将运行状况检查路径从应用服务 ( api.mywebsite.com ) 的 URL 更改为根路径 ( / ) 为我解决了这个问题。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure 应用服务 Docker 容器重启 - Azure App Service Docker Container Restart Error: Internal server error in Azure AD authentication Web App deployed as docker container in Azure web App service - Error : Internal server error in Azure AD authentication Web App deployed as docker container in Azure web App service 在 Azure Web App Service 中使用 redis 作为容器 - Use redis as a container in Azure Web App Service 从 Azure 应用服务(Web App)访问 Azure 容器实例 - Access Azure Container Instance from Azure App Service (Web App) 容器端口 Issue Azure Web App as Container - Container Port Issue Azure Web App as Container 在Azure“应用程序服务”的Tomcat容器中指定WEB-INF的路径 - Specifying path for WEB-INF in Tomcat container in an Azure “App Service” Azure Web 容器应用程序 - 容器无法连接到外部 WCF 服务 - Azure Web App For Containers - Container cannot connect to outside WCF Service Azure容器服务和容器Web应用程序之间的区别 - Difference between Azure Container Service and Web App for Containers Azure Web 自定义容器中的应用程序,环境变量未从应用程序服务传播到容器 - Azure Web App in custom container, env variables not propagated from app service to container 重启 Azure 容器实例 - Restart Azure Container Instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM