YARP container not starting because of too many routes
- 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
When configuring many routes in the Aspire YARP integration (67 in my case, each with transforms), the generated container command seems to exceed the Windows command-line length limit. As a result, the YARP container fails to start with this error:
```bash
fail: Aspire.Hosting.Dcp.dcpctrl.dcpctrl.ContainerReconciler[0]
Could not create the container {"Container": "/ReverseProxy-ctrztfte", "Reconciliation": 41, "ContainerName": "ReverseProxy-ctrztfte", "error": "docker command 'InspectContainers' returned with non-zero exit code 1\nobject not found\ncontainer not found\nError response from daemon: No such container: ReverseProxy-ctrztfte\nnot all requested objects were returned\nonly 0 out of 1 containers were successfully inspected\nfork/exec C:\\Users\\***\\AppData\\Local\\Microsoft\\WinGet\\Packages\\Docker.DockerCLI_Microsoft.Winget.Source_8wekyb3d8bbwe\\docker\\docker.exe: The filename or extension is too long.\nfailed to start Docker command 'CreateContainer'"}
```
This happens because Aspire encodes every YARP route and transform as environment variables, which makes the `docker create` command line very long. On Windows, that eventually seems to exceed the maximum CLI length (~8 KB).
I realize this is partly a Windows limitation, but what’s the intended way to handle larger configurations now?
In previous versions, it was possible to use a config file via `WithConfigFile`, but that method was removed in Aspire 9.4.
I could simplify or reduce my routes, but that only delays the issue as the number of resources grows.
Is the expectation that we create a separate YARP project (rather than using the built-in Aspire integration) to avoid this problem?
### Expected Behavior
The YARP container should start normally regardless of how many routes are configured. Aspire should not exceed Windows’ command-line length when generating container environment variables.
### Steps To Reproduce
Add enough routes/transforms to exceed the command-line limit
### Exceptions (if any)
_No response_
### .NET Version info
.NET SDK:
Version: 9.0.306
Commit: cc9947ca66
Workload version: 9.0.300-manifests.a92bd2c7
MSBuild version: 17.14.28+09c1be848
Aspire version: 9.5.1
IDE: VS 2022 (17.14.16)
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.