如何 运行 Azure 上的容器化控制台应用程序?

how to run containerized console app on Azure?

我有一个容器化的控制台应用程序,运行 作为调度程序应用程序并在特定时间执行一些逻辑。我尝试 运行 它作为 Azure 应用程序服务,但低于错误

2022-03-30T19:10:29.209Z INFO  - Waiting for response to warmup request for container one-site-scheduler-app_0_d429ab9d. Elapsed time = 209.8994308 sec
2022-03-30T19:10:45.377Z INFO  - Waiting for response to warmup request for container one-site-scheduler-app_0_d429ab9d. Elapsed time = 226.067164 sec
2022-03-30T19:10:49.746Z ERROR - Container scheduler-app_0_d for site one-site-scheduler-app did not start within expected time limit. Elapsed time = 230.4276536 sec
2022-03-30T19:10:49.901Z ERROR - Container scheduler-app_0_d didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
2022-03-30T19:10:49.977Z INFO  - Stopping site scheduler-app because it failed during startup.

虽然在它停止容器之前我看到了来自调度程序应用程序的日志。

我不确定我在这里遗漏了什么。

我尝试关注 https://ameshram57.medium.com/azure-app-service-container-container-didnt-respond-to-http-pings-e2e653d867fe#:\~:text=if%20you%20are%20getting%20%E2%80%9C%20ERROR,we%20map%20port%20in%20docker

这篇文章,但没有运气。

我了解到 Azure 应用程序服务默认在端口 80 上执行 ping 操作,以检查它是否收到任何响应,因为我的容器只是 运行 一个控制台应用程序,它从未响应来自应用程序服务的 ping 操作。为了解决这个问题,我使用 webhostbuilder 将我的控制台应用程序转换为单点网络应用程序,并按照以下步骤操作, https://nitishkaushik.com/what-is-webhostbuilder-in-asp-net-core/

这个技巧奏效了。