c# - 如何在 HTTPS 上的 Visual Studio 中本地运行 Azure Function?

标签 c# https visual-studio-2017 azure-functions

我有一个在 Visual Studio 中开发的 C# 库 Azure Function (v1 .Net Framework 4.6.1)。

我想在 HTTPS 上的 Visual Studio 中本地运行它。我怎样才能做到这一点?

我已将我的应用程序参数设置如下:

host start --port 7112 --pause-on-error --useHttps --cors * 

添加 --usehttps 会导致应用程序无法正常启动。

应用程序启动时询问我是否要安装证书,我单击是。

然后控制台窗口显示这个并且应用程序似乎没有正确加载 - 最后的消息一直重复。

Listening on https://localhost:7112/
Hit CTRL-C to exit...
[10/07/2018 15:52:58] Reading host configuration file 'C:\Application.Server\bin\Debug\net461\host.json'
[10/07/2018 15:52:58] Host configuration file read:
[10/07/2018 15:52:58] {}
The host is taking longer than expected to start.

(旁白;我正在尝试这样做,因为我认为这可能对 this 有帮助)。

最佳答案

请尝试在 powershell 中使用以下命令创建测试证书

$cert = New-SelfSignedCertificate -Subject localhost -DnsName localhost -FriendlyName "Functions Development" -KeyUsage DigitalSignature -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1")

Export-PfxCertificate -Cert $cert -FilePath certificate.pfx -Password (ConvertTo-SecureString -String <password> -Force -AsPlainText)

这是启动主机功能的命令

func host start --port 7112 --useHttps --cors * --cert certificate.pfx --password <password>

关于c# - 如何在 HTTPS 上的 Visual Studio 中本地运行 Azure Function?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51269657/

相关文章:

c# - 锁定困惑的串口端口句柄

ssl - 如何通过 HTTPS/SSL 运行 Svelte/Sapper 应用程序?

visual-studio-2017 - VS2017 nuget加载项目依赖失败

asp.net - 有没有办法确保 ASP.NET 应用程序(仅)在 HTTPS 协议(protocol)上运行?

Azure函数: Add environment specific config variable file in VS 2017 Preview 4

c# - 如何从命令 Visual Studio Extension 2017 获取 IWpfTextView

c# - 读取 -> 使用 -> 更新

C# - 确定参数是否已传递失败的方法

c# - 将对象列表写入文本文件

.htaccess - htaccess 将 301 https www 重定向到非 www