如何在 HTTPS 上的 Visual Studio 中本地运行 Azure Function? [英] How to run Azure Function locally within Visual Studio on HTTPS?

查看:38
本文介绍了如何在 HTTPS 上的 Visual Studio 中本地运行 Azure Function?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a C# library Azure Function (v1 .Net Framework 4.6.1) developed in Visual Studio.

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

I want to run this locally within Visual Studio on HTTPS. How can I achieve this?

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

I have set my application arguments as follows:

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

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

Adding --usehttps results in the application not starting correctly.

当应用程序启动时询问我是否要安装证书,我点击是.

When the application starts it asks if I want to install a certificate, I click yes.

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

Then console window shows this and the application doesnt seem to load correctly - the final message just keeps repeating.

Listening on https://localhost:7112/
Hit CTRL-C to exit...
[10/07/2018 15:52:58] Reading host configuration file 'C:Application.ServerinDebug
et461host.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.

(除此之外;我正在尝试这样做,因为我认为它可能有助于 这个).

(Aside; I am trying to do this because I think it might help with this).

推荐答案

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

Please try creating a test cert using following commands in 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)

这是启动功能主机的命令

and here is the command to start functions host

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

这篇关于如何在 HTTPS 上的 Visual Studio 中本地运行 Azure Function?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆