sou*_*uth 3 azure-functions azure-functions-core-tools
我想在 Windows 上本地测试 Azure Function Http 触发器。
我使用 azure-function-core-tools 来运行命令
func start --port 5007 --useHttps
然后我收到错误:自动证书生成目前不适用于 .NET Core 构建。
似乎我应该func start --port 5007 --useHttps --cert certificate.pfx在本地创建自签名证书后使用命令
。
如果有一种方法可以轻松启用https?
就像我使用 .net core webapi 一样,我很容易导出 env:ASPNETCORE_URLS= https://localhost。单击某个按钮后,我可以很好地使用https。我们有这样的事情吗?
或者如果func start --port 5007 --useHttps足够但我错过了一些配置?
谢谢!
更新答案:
func start --port 5007 --useHttps在 azure 功能 v1.0 之后不会自动创建证书。基于 .Net Core 的 azure function v2 和 azure function v3 工具不会为您创建证书。您应该手动生成证书。
原答案:
我可以重现您的错误:
解决方案:
使用管理员启动您的 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")
Run Code Online (Sandbox Code Playgroud)
然后创建证书文件:
Export-PfxCertificate -Cert $cert -FilePath certificate.pfx -Password (ConvertTo-SecureString -String 123 -Force -AsPlainText)
Run Code Online (Sandbox Code Playgroud)
最后,我可以使用 https:(下面的命令在 windows cmd 中运行。)
func host start --port 5007 --useHttps --cors * --cert certificate.pfx --password 123
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1516 次 |
| 最近记录: |