asp.net-core - azure 应用服务中的 Kestrel 地址绑定错误
问题描述
我有一个 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 与其他任何东西。
解决方案
问题原来是应用程序已经在运行,但由于尝试在 azure 应用程序服务中使用 kestrel 而没有接受请求。我不得不用.UseIIS()
它来让它工作。也许我做错了什么。
推荐阅读
- anaconda - 为什么有多个 conda 文件副本?
- java - AndroidRuntime: FATAL EXCEPTION: main in android studio
- python - Numpy间接索引
- spring-boot - 如果某些标头参数不存在,即使我们没有将它们包含在特定请求中,SpringBoot 也会拒绝所有请求
- list - 如何在 Julia 中将 Float 类型的数组转换为 Any?
- sql - SQL 找不到服务器 - 尽管查询正在搜索 DBname 作为服务器
- reactjs - 更改密码时出现“回调不是函数”错误
- virtual-machine - ESXi 虚拟机详细信息
- c# - C# 中的内存到内存和缓冲区大小
- python - Numpy 中的索引