如何在 Visual Studio 中通过 HTTPS 本地运行 Azure Function?

Jam*_*ood 5 c# https azure-functions visual-studio-2017

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

我想在 Visual Studio 中通过 HTTPS 本地运行它。我怎样才能实现这个目标?

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

host start --port 7112 --pause-on-error --useHttps --cors * 
Run Code Online (Sandbox Code Playgroud)

添加--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.
Run Code Online (Sandbox Code Playgroud)

(旁白;我正在尝试这样做,因为我认为这可能会有所帮助

Pra*_*opa 5

请尝试在 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)
Run Code Online (Sandbox Code Playgroud)

这是启动功能主机的命令

func host start --port 7112 --useHttps --cors * --cert certificate.pfx --password <password>
Run Code Online (Sandbox Code Playgroud)