Using 'AsHostedAgent' makes all other resources require explicit compute environment
- 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
Maybe related to [#17754](https://github.com/microsoft/aspire/issues/17754)
I'm experimenting with a foundry hosted agent, and at deploy time I now get:
[All my resources except presumably the agent] are not assigned to a compute environment, but the model contains
multiple compute environments ('cae-ecodriver', 'ecodriverfoundry'),
For my agent I'm using 'AsHostedAgent' assigning to a project on foundry. So the error makes sense, foundry is now another hosting environment for the agent, but at the same time a bit annoying that this one addition breaks everything else making everything require an explicit 'WithComputeEnvironment'.
### Expected Behavior
'AsHostedAgent' should work in an isolated way, i.e the foundry environment treated as an isolated thing so it doesn't make everything else require 'WithComputeEnvironment'.
If that's not feasible, maybe there should should be a concept of the default Compute environment. e.g. an extension on 'AddAzureContainerAppEnvironment', you could have 'AsDefaultComputeEnvironment()', avoiding the need for explicit WithComputeEnvironment on everything if you want to use foundry hosted agents.
### Steps To Reproduce
Create an aspire project with a foundry hosted agent and a web project with no compute environment assigned.
### Exceptions (if any)
From github actions:
[resources] are not assigned to a compute environment, but the model contains
multiple compute environments ('cae-ecodriver', 'ecodriverfoundry'),
### Aspire doctor output
```plain
Aspire Environment Check
========================
Aspire
✅ Aspire CLI version 13.5.2 (channel: stable)
✅ Developer Control Plane (DCP) connection health checks succeeded
AppHost
✅ AppHost version 13.5.2 (ecoDriverWeb.AppHost\ecoDriverWeb.AppHost.csproj)
.NET SDK
✅ .NET 10.0.400 installed (x64)
Container Runtime
✅ Docker v29.7.2: running (auto-detected (default)) ← active
Environment
✅ Operating system: Windows 10.0.26200.0
✅ HTTPS development certificate is trusted
Development Tools
✅ Aspire extension for VS Code is installed
Summary: 8 passed, 0 warnings, 0 failed
Aspire CLI Installations
========================
╭───────────────────────────────────────────────┬──────────────────────────────────────────────┬──────────────┬──────────────┬─────────────╮
│ Path │ Version │ Channel │ Route │ PATH status │
├───────────────────────────────────────────────┼──────────────────────────────────────────────┼──────────────┼──────────────┼─────────────┤
│ C:\Users\MatthewPaul\.aspire\bin\aspire.exe │ 13.5.2+a22cec24d76e764b3681977e314ab4a0aeed0 │ stable │ script │ active │
│ (current) │ 240 │ │ │ │
│ C:\Users\MatthewPaul\.dotnet\tools\aspire.EXE │ (not probed) │ (not probed) │ (not probed) │ shadowed │
╰───────────────────
```
### Anything else?
_No response_
Contributor guide
Research direction
Reproduce the deployment with AsHostedAgent, a Foundry project, and a web project without WithComputeEnvironment. Start by tracing how AsHostedAgent and WithComputeEnvironment are handled when multiple compute environments exist; done means the hosted agent remains isolated and other resources deploy without unnecessary explicit assignment, with the reported scenario covered by regression tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100