我已经在自定义
ForceHttps
中设置了 OpenApiConfigurationOptions
选项,但在本地通过 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"
您可以直接运行您的函数来使用
Https
,如下所示:-
我直接创建了一个
Http with OpenAPI Trigger
.net 6.0
并使用以下命令从 Visual Studio Terminal 运行它:-
func start --port 7071 --useHttps
参考- 如何在进行本地测试时轻松启用azure功能https - Stack Overflow,作者:Cindy Pau