microsoft / microsoft/aspire

Azure Function url is different from the Aspire defined url

Open
#10,721 4 comments 0 reactions 0 assignees View on GitHub
area-integrations azure azure-functions
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 12h
Merged PRs (30d)
201

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

Created a new .NET Aspire project, added a new Azure Functions project which is enlisted in Aspire.
When running the AppHost, I can see the function gets launched with a url on port 7280.
But when triggering the function on that port or browsing to that port doesn't work.

When going into the logs of the functions project, I see port 7071 is used, so not the one from the AppHost.

LaunchSettings file in Azure functions:

```{
"profiles": {
"FirstAspireProjectFunctions": {
"commandName": "Project",
"commandLineArgs": "--port 7280",
"launchBrowser": false
}
}
}
```

Things I have tried:

- Edit the registration of the azure functions project with:

`.WithArgs("--host", "localhost", "--port", "7280")`

This works, I can see now that the port 7280 is used for the function url.

- Edit the launchSettings file in the azure functions project to include host localhost:

```{
"profiles": {
"FirstAspireProjectFunctions": {
"commandName": "Project",
"commandLineArgs": "--host localhost --port 7280",
"launchBrowser": false
}
}
}
```

This doens't work.

### Expected Behavior

Expected to see the Azure functions url with the port defined by the AppHost.

### Steps To Reproduce

_No response_

### Exceptions (if any)

_No response_

### .NET Version info

_No response_

### Anything else?

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Azure Functions project through the Aspire AppHost, comparing the port from launchSettings with the URL shown by the AppHost. Inspect the project registration and the launchSettings command-line arguments, then verify that triggering the displayed URL reaches the function without requiring manual --port arguments.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
backend, cloud
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.