如何在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:\GTFS\Girlguiding\Gapconsulting.Girlguiding.MSCRM\Gapconsulting.Girlguiding.MSCRM.Companion.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.
(旁白;我试图这样做,因为我认为它可能有助于此 )。
请尝试使用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
- 在Async方法中绑定到输出blob时,将Blob绑定到IAsyncCollector时出错
- Azurefunction:仅为新事件配置blob触发器
- Azurefunction角色,如停止Azure虚拟机的权限
- 如何设置function应用程序以从媒体类型’application / x-www-form-urlencoded’中提取数据
- 不接受Azurefunction(ILogger或TraceWriter)的上次日志记录参数
- 部署的Azurefunction(v2)未运行
- 预编译的Azurefunction和CloudTable绑定输出不起作用
- 执行测试时出错,如果使用CreateResponse扩展方法返回Azure Function HttpResonseMessage
- 如何使用Azure Functions删除blob?