【问题标题】:Kestrel address binding errors in azure app serviceazure 应用服务中的 Kestrel 地址绑定错误
【发布时间】:2019-07-17 18:27:26
【问题描述】:

我有一个 aspnet core 2.2 应用程序,如下所示:

return WebHost.CreateDefaultBuilder(args)
    .ConfigureAppConfiguration((builderContext, config) =>
    {
        var env = builderContext.HostingEnvironment;

        config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
    })
    .UseStartup<Startup>()
    .UseKestrel(options =>
    {
        options.ConfigureHttpsDefaults(opts =>
        {
            opts.ServerCertificate = GetCertificate();
            opts.ClientCertificateMode = ClientCertificateMode.RequireCertificate;
            opts.ClientCertificateValidation = CertificateValidator.DisableChannelValidation;
        });
    });

一切都在本地运行良好。但是,当部署到 azure 应用服务时,我得到以下信息:

Unhandled Exception: System.IO.IOException: Failed to bind to address http://127.0.0.1:5000: address already in use

我在这里有什么特别需要做的不同吗?只要我可以执行客户端证书身份验证(在我当前的实现中本地工作),我并不特别关心使用 Kestrel 与其他任何东西。

【问题讨论】:

    标签: asp.net-core azure-web-app-service azure-webapps


    【解决方案1】:

    问题原来是应用程序已经在运行,但由于尝试在 azure 应用服务中使用 kestrel 而没有接受请求。我不得不使用.UseIIS() 让它工作。也许我做错了什么。

    【讨论】:

      【解决方案2】:

      如果您已经知道您的应用程序是什么端口。将始终使用,使用UseUrls 将其编码到您的应用程序中可能是有意义的:

      .UseUrls(urls: "http://localhost:10000")
      

      或者像这样issue运行dotnet run --urls="http://localhost:10000"

      【讨论】:

        猜你喜欢
        • 2017-12-07
        • 2018-10-06
        • 1970-01-01
        • 2011-01-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-08-04
        相关资源
        最近更新 更多