Skip to content

[Agents Extension] agent run fix for .net#7729

Merged
rajeshkamal5050 merged 2 commits into
mainfrom
trangevi/invoke-port-bug
Apr 15, 2026
Merged

[Agents Extension] agent run fix for .net#7729
rajeshkamal5050 merged 2 commits into
mainfrom
trangevi/invoke-port-bug

Conversation

@trangevi

Copy link
Copy Markdown
Member

Fixes #7688

Adds proper env var for local .net run

Signed-off-by: trangevi <trangevi@microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes local .NET agent runs by ensuring the correct environment variable is set so ASP.NET Core binds to the intended port.

Changes:

  • Detect project type earlier in runRun to reuse for start command resolution and environment setup.
  • Add ASPNETCORE_URLS when the detected project language is dotnet.
  • Add tests intended to validate .NET vs non-.NET env var behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cli/azd/extensions/azure.ai.agents/internal/cmd/run.go Adds early project-type detection and sets ASPNETCORE_URLS for .NET runs.
cli/azd/extensions/azure.ai.agents/internal/cmd/run_test.go Adds tests around expected env var composition for .NET and non-.NET projects.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/run_test.go Outdated
Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/run.go Outdated

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is correct - .NET projects need ASPNETCORE_URLS to tell Kestrel which port to bind to, since it ignores the PORT env var. Moving detectProjectType earlier so it's available for both command detection and env setup is the right approach.

One concern: the tests re-implement the env-building logic inline rather than testing the actual production code path. If the ASPNETCORE_URLS block were removed from runRun(), all 4 subtests would still pass.

Nit: detectProjectType(projectDir) is now called twice per run - once at the top of runRun and again inside installDependencies. Consider passing pt to avoid the redundant file checks.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/run_test.go Outdated
Signed-off-by: trangevi <trangevi@microsoft.com>
@rajeshkamal5050

Copy link
Copy Markdown
Contributor

/check-enforcer override

@rajeshkamal5050
rajeshkamal5050 merged commit 5ad9209 into main Apr 15, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

azd ai agent run on .net projects incorrectly says port 8088

5 participants