Csharp/C#教程:如何在HTTPS上的Visual Studio中本地运行Azurefunction?分享


如何在HTTPS上的Visual Studio中本地运行Azurefunction?

我有一个在Visual Studio中开发的C#库Azure函数(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:GTFSGirlguidingGapconsulting.Girlguiding.MSCRMGapconsulting.Girlguiding.MSCRM.Companion.ServerbinDebugnet461host.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. 

(旁白;我试图这样做,因为我认为它可能有助于此 )。

请尝试使用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  -Force -AsPlainText) 

这是启动function主机的命令

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

经过一段时间的努力,我找到了使用ngrok的解决方法。

Piotr Stapp描述了这个过程 。

跑 。 ngrok authtoken aaa生成配置文件。 它的位置将打印为输出…用以下内容替换内容:

 tunnels: azurefunction: proto: http addr: 7071 host_header: localhost 

从Visual Studio使用F5和PowerShell(或cmd)类型在localhost上运行Azurefunction:

.ngrok.exe start azurefunction

上述就是C#学习教程:如何在HTTPS上的Visual Studio中本地运行Azurefunction?分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/992292.html

(0)
上一篇 2021年12月24日
下一篇 2021年12月24日

精彩推荐