Open nanan1993 opened 4 years ago
@nanan1993 Can you share the full output of the command? It should show some instructions on how to set up a cert. Also, what platform are you running on? Thanks.
Thanks for your quick reply.
I worked on Win10 locally.
Here is the instructions you mentioned and I know how it will work.
I am wondering if we can straightly use command func host start --port 5007 --useHttps
to start but not to add "--cert certificate.pfx" every time. As I remember, when testing webapi, I do not need to know where the .pfx file is.
What exactly I want is a way to automatically generate a default debug cert and use it when start functions. So that I do not necessarily need to create a cert file by myself. Creating, Trusting , Adding cert file ... all the things will be done by tools, I just need to say "hey, I want a https trigger" and every thing prepared for me like a magic. As I know webapi did it when I debug.
Do we have it in azure function?
With azure core tools version 4.0, it appears that --useHttps
works fine to generate a self-signed certificate:
(.venv) PS C:\azure> func start --useHttps
Found Python version 3.9.13 (py).
Azure Functions Core Tools
Core Tools Version: 4.0.5198 Commit hash: N/A (64-bit)
Function Runtime Version: 4.21.1.20667
Generating a self signed certificate using openssl
Functions:
...
Hm... I get:
(.venv) PS C:\Users\me\Documents\projects\myproject> func start --useHttps
Found Python version 3.8.10 (py).
Azure Functions Core Tools
Core Tools Version: 4.0.5348 Commit hash: N/A (64-bit)
Function Runtime Version: 4.24.5.21262
Auto cert generation is currently not working on the .NET Core build.
On Windows you can run:
PS> $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")
PS> Export-PfxCertificate -Cert $cert -FilePath certificate.pfx -Password (ConvertTo-SecureString -String <password> -Force -AsPlainText)
For more checkout https://docs.microsoft.com/en-us/aspnet/core/security/https
Auto cert generation is currently not working on the .NET Core build.
@ericthomas1 you are probably using pwsh... try the 'old' powershell
I want to test Azure Function Http trigger locally on windows.
When I run
func start --port 5007 --useHttps
I got error : Auto cert generation is currently not working on the .NET Core build.It seems like that I should use command
func start --port 5007 --useHttps --cert certificate.pfx
after I creating a self-signed certificate locally.Is there a way to enable https easily?
The way like when I use .net core webapi, I easily export env:ASPNETCORE_URLS=https://localhost. Then I set up https well. Do we have some thing like this?
Or if
func start --port 5007 --useHttps
is enough but I missed some configuration?