Fixes Foundry Hosted Agents HTTP endpoints#16130
Fixes Foundry Hosted Agents HTTP endpoints#16130tommasodotNET wants to merge 20 commits intomicrosoft:mainfrom
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16130Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16130" |
There was a problem hiding this comment.
Pull request overview
Updates the Foundry hosted-agent run-mode behavior to avoid endpoint conflicts when PublishAsHostedAgent is applied to resources that already define HTTP endpoints, and adds a new playground sample for hosted agents.
Changes:
- In run mode, removes existing HTTP/HTTPS endpoint annotations before adding the hosted-agent HTTP endpoint.
- Refactors publish-mode containerization to explicitly handle
ProjectResourcevsExecutableResource. - Adds a
playground/FoundryHostedAgentssample (AppHost + Python agent app scaffolding).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Aspire.Hosting.Foundry.Tests/HostedAgentExtensionTests.cs | Adds tests asserting hosted-agent run-mode endpoint overwrite behavior and non-hardcoded port behavior. |
| src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs | Implements endpoint removal in run mode and adjusts publish-mode containerization logic. |
| playground/FoundryHostedAgents/aspire.config.json | Adds Aspire config pointing to the new playground AppHost. |
| playground/FoundryHostedAgents/app/pyproject.toml | Adds Python agent sample dependencies/config. |
| playground/FoundryHostedAgents/app/main.py | Adds Python agent sample implementation. |
| playground/FoundryHostedAgents/app/.dockerignore | Adds Docker ignore rules for the Python sample. |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/appsettings.json | Adds logging configuration for the new AppHost sample. |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/appsettings.Development.json | Adds development Azure settings for the sample (currently includes specific identifiers). |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/Properties/launchSettings.json | Adds launch profiles for the new AppHost sample. |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/FoundryHostedAgents.AppHost.csproj | Adds a new AppHost project file for the playground sample. |
| playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/AppHost.cs | Adds the new playground AppHost wiring for Foundry + Python hosted agent. |
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs
Outdated
Show resolved
Hide resolved
playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/appsettings.Development.json
Outdated
Show resolved
Hide resolved
tests/Aspire.Hosting.Foundry.Tests/HostedAgentExtensionTests.cs
Outdated
Show resolved
Hide resolved
…settings.Development.json Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…m:tommasodotNET/aspire into fix/hosted-agent-overwrite-http-endpoints
…sion.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…m:tommasodotNET/aspire into fix/hosted-agent-overwrite-http-endpoints
|
UPDATE: instead of removing the existing endpoints, we can overwrite them. looks like a better solution. The fix still enables use with dotnet hosted agents (sample added). |
playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/AppHost.cs
Outdated
Show resolved
Hide resolved
playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/AppHost.cs
Outdated
Show resolved
Hide resolved
playground/FoundryHostedAgents/FoundryHostedAgents.AppHost/AppHost.cs
Outdated
Show resolved
Hide resolved
src/Aspire.Hosting.Foundry/HostedAgent/HostedAgentBuilderExtension.cs
Outdated
Show resolved
Hide resolved
|
|
||
| var tenantId = builder.AddParameterFromConfiguration("tenant", "Azure:TenantId"); | ||
|
|
||
| var foundry = builder.AddFoundry("aif-myfoundry"); |
There was a problem hiding this comment.
We should consider making a deployment end-to-end test out of this.
See https://github.com/microsoft/aspire/tree/main/.github/skills/deployment-e2e-testing and https://github.com/microsoft/aspire/tree/main/tests/Aspire.Deployment.EndToEnd.Tests
There was a problem hiding this comment.
i've tried adding one. not sure if it's correct, though
…ntBuilderExtension
…package versions to 1.1.0 and 10.4.0 respectively
| .AddProject("my-project"); | ||
|
|
||
| var app = builder.AddPythonApp("agent", "./app.py", "main:app") | ||
| .WithHttpEndpoint(name: "http", targetPort: 5000) |
There was a problem hiding this comment.
| .WithHttpEndpoint(name: "http", targetPort: 5000) | |
| .WithHttpEndpoint(targetPort: 5000) |
| Assert.True(app.Resource.TryGetEndpoints(out var endpoints)); | ||
| var httpEndpoints = endpoints.Where(e => e.Name == "http").ToList(); | ||
| Assert.Single(httpEndpoints); | ||
| Assert.Equal(8088, httpEndpoints[0].TargetPort); |
There was a problem hiding this comment.
? shouldn't this be 5000
Description
Closes #16115. Overwrites existing http/https endpoints on resource to allow the creation of dedicated hosted agent endpoint. Does not hard code http port (letting aspire handle port assignment).
PublishAsHostedAgentaccepts generic resource with endpoint (e.g. ProjectResource) allowing hosted agents in dotnet (see also #15968).Allows for custom targetPorts to allow locally run multiple hosted agents
Adds a playground sample for hosted agents in python
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: