【发布时间】:2021-06-09 07:56:46
【问题描述】:
我在 docker 和 Azure Service Fabric 中有一个 Asp.net core 3.1 Web 应用程序。
asp.net 核心 Web 应用已启用 https 并从 AzureKeyVault 获取其证书。部署时,似乎 https 没有响应,但 http 可以工作。
控制台主机看起来如此
public static void ConfigureKestrelServer(this IWebHostBuilder host)
{
try
{
host.ConfigureKestrel(options =>
{
options.ConfigureHttpsDefaults(listenOptions =>
{
listenOptions.ServerCertificate = GetCertificateFromStore();
});
});
}
catch (System.Exception e)
{
throw;
}
}
public static X509Certificate2 GetCertificateFromStore()
{
return AzureKeyVaultExtensions.GetCertificateSecretAsync().GetAwaiter().GetResult();
}
上面的代码可以在部署时下载证书。 docker 文件是这样的
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
ARG source
WORKDIR /app
ADD ${source} .
ENV APP_UTILS=C:\\app
VOLUME ${APP_UTILS}
EXPOSE 80
EXPOSE 443
ENTRYPOINT ["dotnet", "MyWebApp.dll"]
【问题讨论】:
-
尝试将
ENTRYPOINT移到EXPOSE下方。
标签: c# docker asp.net-core azure-keyvault