HTTPS endpoint + certificate configuration issues with Azure Function
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 196
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
We want to enable certificate for an Azure Function project (for whatever reason, that's not the point here).
If we want to configure an Azure function project with a certificate, we can do:
```
func
.WithHttpsCertificateConfiguration(ctx =>
{
ctx.Arguments.Add("--cert");
ctx.Arguments.Add(ctx.PfxPath);
ctx.Arguments.Add("--password");
ctx.Arguments.Add(ctx.Password!);
return Task.CompletedTask;
});
```
To make Aspire understand that we need the Azure Function with HTTPS, we need to add in the `launchSettings.json`: `"commandLineArgs": "--useHttps"` otherwise the resource endpoint is not HTTPS (as per `AddAzureFunctionsProject ` implementation).
But if you configure args with `WithHttpsCertificateConfiguration` , it removes the `--useHttps` from the `launchSettings.json`! So you need to add it again...
At the end I needed to have `WithHttpsCertificateConfiguration` as:
```
func
.WithHttpsCertificateConfiguration(ctx =>
{
ctx.Arguments.Add("--useHttps");
ctx.Arguments.Add("--cors");
ctx.Arguments.Add("*");
ctx.Arguments.Add("--cert");
ctx.Arguments.Add(ctx.PfxPath);
ctx.Arguments.Add("--password");
ctx.Arguments.Add(ctx.Password!);
return Task.CompletedTask;
});
```
It's like playing Hide-and-Seek with args!
The way `AddAzureFunctionsProject` decide to switch to HTTPS endpoint is far too restrictive.
### Expected Behavior
Args should be merged or the `AddAzureFunctionsProject` should understand also args provided in `WithHttpsCertificateConfiguration` to switch to HTTPS endpoint or add a new methods to configure everything in on place.
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### Aspire doctor output
Aspire Environment Check
========================
.NET SDK
✅ .NET 10.0.203 installed (x64)
Container Runtime
✅ Docker v29.4.1: running (auto-detected (default)) ← active
Environment
✅ HTTPS development certificate is trusted
### Anything else?
_No response_
Contributor guide
Research direction
Start by tracing AddAzureFunctionsProject and WithHttpsCertificateConfiguration, then inspect how their arguments interact with launchSettings.json. Verify the current endpoint-selection behavior and whether certificate arguments replace existing arguments. Done means the HTTPS endpoint is recognized without requiring users to re-add --useHttps, with tests covering the configuration path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100