【发布时间】:2017-10-12 10:18:48
【问题描述】:
我有一个在本地运行良好的 .NET Core 1.1 Web Api 项目。一旦我将它部署到 Azure 上的 AppService,它就不会响应任何 GET 请求——它们都会超时。我有一个开放的 ping 端点,它只返回当前日期和时间,但没有响应。查看日志我看到了这一点:
[INF] Azure Web Sites environment detected. Using '"D:\home\ASP.NET\DataProtection-Keys"' as key repository; keys will not be encrypted at rest. (383ad3af)
[WRN] Unable to bind to http://localhost:22676 on the IPv6 loopback interface. (de7f78a0)
System.AggregateException: One or more errors occurred. (Error -4090 EADDRNOTAVAIL address not available) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -4090 EADDRNOTAVAIL address not available
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind(UvTcpHandle handle, SockAddr& addr, Int32 flags)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListener.CreateListenSocket()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<StartAsync>b__8_0(Object state)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
---> (Inner Exception #0) Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -4090 EADDRNOTAVAIL address not available
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind(UvTcpHandle handle, SockAddr& addr, Int32 flags)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind(ServerAddress address)
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListener.CreateListenSocket()
at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<StartAsync>b__8_0(Object state)<---
我不确定为什么会发生这种情况以及如何解决它。
编辑:这是 Program.cs
public static void Main(string[] args)
{
var configuration = new ConfigurationBuilder()
.AddEnvironmentVariables()
.AddCommandLine(args)
.Build();
var host = new WebHostBuilder()
.ConfigureLogging(options => options.AddConsole())
.ConfigureLogging(options => options.AddDebug())
.UseConfiguration(configuration)
.UseIISIntegration()
.UseKestrel(options =>
{
options.ThreadCount = 1;
})
.UseStartup<Startup>()
.Build();
host.Run();
}
【问题讨论】:
-
显示如何配置主机(默认情况下 - Program.cs 文件中的“Main”方法)。你在那里添加了“.UseAzureAppServices()”吗?
-
添加了 Program.cs。我没有使用 UseAzureAppServices()。这是必需的吗?
-
我添加了依赖项并包含了对 UseAzureAppServices() 的调用,但没有任何区别。
标签: azure .net-core asp.net-core-webapi