Serve the Azure Functions host over HTTPS in the Functions sample#1691
Serve the Azure Functions host over HTTPS in the Functions sample#1691IEvangelist wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Updates the aspire-with-azure-functions sample so the local Azure Functions host can be served over HTTPS, aligning the Functions endpoint with the frontend’s HTTPS usage and avoiding Core Tools’ inability to auto-generate a cert on the .NET build.
Changes:
- Add
--useHttpsto the Functions project launch profile so Aspire registers anhttpsendpoint. - Update the AppHost to display the Functions URL via the
httpsendpoint and (in run mode) export the trusted dev cert and pass it tofunc host startvia--cert/--password.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| samples/aspire-with-azure-functions/ImageGallery.Functions/Properties/launchSettings.json | Adds --useHttps to ensure the local Functions host is started in HTTPS mode. |
| samples/aspire-with-azure-functions/ImageGallery.AppHost/AppHost.cs | Switches the displayed Functions endpoint to https and wires dev-cert export + func args in run mode. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var functionsCertPassword = builder.AddParameter( | ||
| "functions-cert-password", () => Guid.NewGuid().ToString("N"), secret: true); |
There was a problem hiding this comment.
Given this is only done in run mode, is there any benefit to this being a parameter? Is it just so we can mark it a secret so it gets hidden in the dashboard UI? Parameters show up in the UI and add code here so just want to make sure there's a reasonable benefit.
nit: wrapping
There was a problem hiding this comment.
Also why use a guid when parameters already handle password generation
Use Aspire's generated parameter support for the local Functions HTTPS certificate password and keep the experimental certificate API warning suppression scoped to the run-mode certificate configuration. Fixes #752 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
032cc42 to
3a67060
Compare
Add explicit Microsoft.OpenApi references where restore resolved a vulnerable transitive version and update file-based AppHost Aspire package directives to 13.4.6 to avoid vulnerable MessagePack transitive dependencies. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fixes #752
Problem
In the
aspire-with-azure-functionssample, the local Azure Functions host (func host start) was only ever served over HTTP. Simply adding--useHttpsto the Functions launch profile is not enough — the .NET build of Azure Functions Core Tools cannot auto‑generate a certificate and fails to start:func host start --useHttpsrequires an explicit password‑protected PFX via--cert/--password.Fix
ImageGallery.Functions/Properties/launchSettings.json— add--useHttpsso Aspire registers anhttpsendpoint for the Functions resource.ImageGallery.AppHost/AppHost.cs—WithUrlForEndpointat thehttpsendpoint.WithHttpsDeveloperCertificate(...)and hand the resulting PFX to the Functions host withWithHttpsCertificateConfiguration(...)(--cert <pfx> --password <generated>). The export password is an ephemeral, per‑run secret parameter, so nothing is committed. The wiring is guarded byIsRunModeso it never affects publish/deploy.Effective local launch becomes:
Verification (local)
Tested locally with .NET 10, Aspire 13.4.3, Azure Functions Core Tools v4.12.0, Docker (Azurite):
Before —
curl http://localhost:7221/admin/host/status→200; HTTPS TLS handshake fails (SEC_E_INVALID_TOKEN).After
funclaunches with--useHttps --cert <pfx> --password <generated>and listens on:7221.curl https://localhost:7221/admin/host/status(no-k) →200 OKwith{"state":"Running","version":"4.1048..."}— i.e. served over HTTPS using the trusted dev cert.http://localhost:7221/...now fails (port is HTTPS‑only).200).imagescontainer → theThumbnailGeneratorblob trigger produced a 170×128 thumbnail inthumbnails. The pipeline is unaffected.Prerequisite
A trusted ASP.NET Core developer certificate (
dotnet dev-certs https --trust) — already part of the Aspire prerequisites linked in the sample README.