我已经在我的定制OpenApiConfigurationOptions中设置了ForceHttps选项,但当在本地运行它到http://localhost:7071/api/swagger/ui时,仍然只获得http中的内容.以下是我的定制配置:

public class OpenApiConfigurationOptions : DefaultOpenApiConfigurationOptions
{
    public override bool ForceHttps { get; set; } = true;
    public override OpenApiInfo Info { get; set; } = new OpenApiInfo()
    {
        Version = "1.0.0",
        Title = "OpenAPI Document ",
        Description = "An adapter",
        Contact = new OpenApiContact()
        {
            Name = "N/A",
            Email = "N/A",
            Url = null,
        },
        License = new OpenApiLicense()
        {
            Name = "MIT",
            Url = new Uri("http://opensource.org/licenses/MIT"),
        }
    };

}

我用的是"Microsoft.Azure.WebJobs.Extensions.OpenApi" Version="1.5.1"

推荐答案

101

我直接创建了一个Http with OpenAPI Trigger .net 6.0,并使用来自Visual Studio Terminal的以下命令运行它:-

enter image description here

func start --port 7071 --useHttps

enter image description here

enter image description here

Reference - How to enable azure function https easily when do local test - Stack Overflow位作者:辛迪·鲍尔

Csharp相关问答推荐

Serilog SQL服务器接收器使用UTC作为时间戳

C#使用属性和值将JSON转换为XML

错误401未授权ASP.NET Core.使用JWT创建身份验证/授权

C#DateTime.ToString在ubuntu和centos中返回不同的结果

System.Net.Http.HttpClient.SendAsync(request)在docker容器内的POST方法30秒后停止

Automapper 12.x将GUID映射到字符串

C#DateTime.ParseExact不使用特定日期

使用Dapper映射联接查询对象数据到使用SplitOn;

C#中Java算法的类似功能

从另一个不同 struct 的数组创建Newtonsoft.Json.Linq.J数组

具有以接口为其类型的属性的接口;类指定接口的实现,但无效

Linux Docker上的.NET6在某个时间抛出后,在加密操作期间发生System.Security.Cryptography.CryptographicException:错误

如何管理Azure认证客户端响应和证书 fingerprint

在.NET 8最低API中从表单绑定中排除属性

RX操作员使用先前值进行扫描,信号来自值本身

实体框架-IsRequired()与OnDelete()

使用C#12中的主构造函数进行空判断

为什么连接到Google OAuth2后,结果.Credential为空?

将带有嵌套If-Else的Foreach循环转换为Linq表达式

XmlSerializer在遇到XML属性(命名空间)时崩溃