我正在使用 Visual Studio 中的“发布”功能将 ASP.NET Core 8.0 Razor 页面 Web 应用程序从 Visual Studio 部署到 Azure 应用服务 (Linux)。 (更新 2:小型 Web API 项目也存在同样的问题)
从 Visual Studio 输出来看,一切似乎都成功了:
Waiting for Web App to be ready...
Restarting the Web App...
Successfully restarted Web App.
Web App is ready.
Visual Studio 打开网站,似乎可以工作,但深入查看后,旧版本的网站仍在运行。几秒钟后,整个网站在大约 60 秒内不再响应。经过这么长一段时间,新版本的Web应用程序可以正常运行了。
“日志流”有一些非常有趣的细节。看起来
Site startup probe failed
,然后导致容器被完全删除并重新创建。
2025-01-19T15:42:48.2577054Z Container is running.
2025-01-19T15:42:49.1677192Z Container start method finished after 2853 ms.
2025-01-19T15:42:55.7255545Z Site startup probe failed after 6.5570944 seconds.
2025-01-19T15:42:55.7662020Z Failed to start site. Revert by stopping site.
2025-01-19T15:42:55.7736491Z Container is terminating. Grace period: 5 seconds.
2025-01-19T15:42:55.8253983Z Stop and delete container. Retry count = 0
更新/更多信息:
我尝试了服务计划“Linux Basic B1”。在它不能正常工作后,我什至切换到“Linux Basic B2”。但问题依然存在。
注意:以前,它托管为“Windows Shared D1”,运行没有问题(我的网站很小)。但由于我想要 SSL (https),Windows 中的下一个可能步骤将花费 50 美元/月,这太高了。这就是我尝试切换到 Linux 的原因。
更新2:
在 20 次尝试中大约有 1 次,一切正常,没有任何明显的停机时间。在这些罕见的情况下,“站点启动探测成功”,但有趣的是,时间并不比失败时短。例如,站点启动探测可能会在 6.5 秒后失败,而站点启动探测可能会在 7 秒后成功。所以,似乎没有硬超时。问题可能出在其他地方。
更详细的日志:
2025-01-19T15:42:46.3136340Z Container start method called.
2025-01-19T15:42:46.3137398Z Establishing network.
2025-01-19T15:42:46.3138407Z Pulling image: appsvc/dotnetcore:8.0_20241021.7.tuxprod.
2025-01-19T15:42:47.4967821Z Container is starting.
...
2025-01-19T15:42:47.8176584Z Creating container.
2025-01-19T15:42:47.8183404Z Creating pipes for streaming container io.
...
2025-01-19T15:42:47.8373506Z Creating container with image: appsvc/dotnetcore:8.0_20241021.7.tuxprod from registry: 10.1.0.11:13209 and fully qualified image name: 10.1.0.11:13209/appsvc/dotnetcore:8.0_20241021.7.tuxprod
2025-01-19T15:42:48.1991657Z Starting container: ⬛⬛⬛⬛⬛⬛_b6972ab4.
2025-01-19T15:42:48.2572329Z Starting watchers and probes.
2025-01-19T15:42:48.2575996Z Starting metrics collection.
2025-01-19T15:42:48.2577054Z Container is running.
2025-01-19T15:42:49.1677192Z Container start method finished after 2853 ms.
2025-01-19T15:42:55.7255545Z Site startup probe failed after 6.5570944 seconds.
2025-01-19T15:42:55.7662020Z Failed to start site. Revert by stopping site.
2025-01-19T15:42:55.7736491Z Container is terminating. Grace period: 5 seconds.
2025-01-19T15:42:55.8253983Z Stop and delete container. Retry count = 0
2025-01-19T15:42:55.8424404Z Stopping container: ⬛⬛⬛⬛⬛⬛_b6972ab4.
2025-01-19T15:42:57.7267554Z Deleting container: ⬛⬛⬛⬛⬛⬛_b6972ab4. Retry count = 0
2025-01-19T15:42:58.3888185Z Container spec TerminationMessagePolicy path
2025-01-19T15:42:58.3889615Z Site container: ⬛⬛⬛⬛⬛⬛ terminated during site startup.
2025-01-19T15:43:00.4359012Z Site: ⬛⬛⬛⬛⬛⬛ stopped.
2025-01-19T15:43:20.4640653Z Container is terminating. Grace period: 5 seconds.
2025-01-19T15:43:20.4673161Z Stop and delete container. Retry count = 0
2025-01-19T15:43:20.4673771Z Stopping container: ⬛⬛⬛⬛⬛⬛_4aa5f291.
2025-01-19T15:43:20.9852430Z Deleting container: ⬛⬛⬛⬛⬛⬛_4aa5f291. Retry count = 0
2025-01-19T15:43:21.6001312Z Container spec TerminationMessagePolicy path
2025-01-19T15:43:21.6006855Z Container is terminated. Total time elapsed: 1136 ms.
2025-01-19T15:44:22.3975090Z Container start method called.
2025-01-19T15:44:22.3975773Z Establishing network.
2025-01-19T15:44:22.3976051Z Pulling image: appsvc/dotnetcore:8.0_20241021.7.tuxprod.
2025-01-19T15:44:23.6242079Z Container is starting.
...
2025-01-19T15:44:25.4407465Z Creating container.
2025-01-19T15:44:25.4417898Z Creating pipes for streaming container io.
...
2025-01-19T15:44:25.4710857Z Creating container with image: appsvc/dotnetcore:8.0_20241021.7.tuxprod from registry: 10.1.0.11:13209 and fully qualified image name: 10.1.0.11:13209/appsvc/dotnetcore:8.0_20241021.7.tuxprod
2025-01-19T15:44:25.7854259Z Starting container: ⬛⬛⬛⬛⬛⬛_d0f411e6.
2025-01-19T15:44:25.8405598Z Starting watchers and probes.
2025-01-19T15:44:25.8475256Z Starting metrics collection.
2025-01-19T15:44:25.8480311Z Container is running.
2025-01-19T15:44:27.8364871Z Container start method finished after 5438 ms.
2025-01-19T15:44:34.3183592Z Site startup probe succeeded after 6.474128 seconds.
2025-01-19T15:44:34.3217562Z Site started.
2025-01-19T15:44:34.3398997Z Site is running with deployment version: 1df661de-f075-4fa7-be58-950e022f900f
第一个
Site startup probe failed
的原因可能是什么,然后导致整个耗时的删除所有内容并从头开始创建所有内容的行为?
我使用 Visual Studio 将
Asp.Net
Core 8 Razore Web App 部署到 Azure Web App 服务 Linux。
即使我在使用
Free App Service plan
时从Azure Web App的日志流中观察到相同的日志。
免费计划资源有限,可能会导致容器启动缓慢。大型应用程序,例如
ASP.NET
Core 8.0,可能无法按时启动,导致启动失败。
免费计划不支持
Always On
功能,保持应用程序处于活动状态并准备就绪,防止部署后出现延迟。
为避免出现此问题,请将应用服务计划更新为基本或更高版本计划。
Azure 输出: