-1

我了解到,运行 .NET 控制台应用程序和 Azure Web App for Containers 并不是那么简单。原因是控制台应用程序需要响应 Azure 运行时的 ping。如果应用程序未能响应,则视为无响应并关闭。

现在应该可以从控制台应用程序回答这些 ping,不是吗?这样的应用程序会是什么样子?

我试过这个,无济于事:

using System.Net;    
var listenToAddress = "http://localhost:80/";
var _httpListener = new HttpListener { Prefixes = { $"{listenToAddress}" } };
_httpListener.Start();
while (true)
{
    var context = await _httpListener.GetContextAsync();
    context.Response.StatusCode = 200;
    context.Response.Close();
}

这应该侦听端口 80 上的请求并始终返回成功。它似乎不起作用。我希望这只是一个需要调整才能运行的细节。

到目前为止,我总是遇到“没有响应 HTTP pings”错误:

INFO  - Waiting for response to warmup request for container app-console-test-westeurope_0_7ccb74c8. Elapsed time = 219.056086 sec
ERROR - Container app-console-test-westeurope_0_7ccb74c8 for site app-console-test-westeurope did not start within expected time limit. Elapsed time = 230.328528 sec
ERROR - Container app-console-test-westeurope_0_7ccb74c8 didn't respond to HTTP pings on port: 80, failing site start. See container logs for debugging.
INFO  - Stopping site app-console-test-westeurope because it failed during startup.

必须做什么才能回答运行时的“ping”?这个 ping 看起来如何?HttpListener 是处理它的正确工具吗?网址是否正确?它是http / https的东西吗?它是否需要一个非 0 的身体作为答案?

也许知道的人可以插话。

4

0 回答 0