-
Notifications
You must be signed in to change notification settings - Fork 715
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When the azure core function tools are started within aspire by Visual Studio a temporary file is created which is used to attach the debugger. The name of the temporary file is the same for all running instances of the same function, which means if you run the same azure function twice only one will start.
Expected Behavior
Aspire dashboard starts by pressing F5 in visual studio. Both azure functions, both show running (green)
Steps To Reproduce
To reproduce using the sample repo
- Remove the line from launchsettings.json of the function
commandLineArgsas we need to able to specify the ports -
` var builder = DistributedApplication.CreateBuilder(args); builder.AddAzureFunctionsProject<Projects.FunctionApp1>("functionapp1-first") .WithArgs($"--verbose") .WithEndpoint("http", (endpointBuilder) => { endpointBuilder.Port = 6074; endpointBuilder.TargetPort = 6074; endpointBuilder.IsProxied = false; }) .WithEnvironment("WEBSITE_HOSTNAME", "localhost:6074") .WithEnvironment("ASPNETCORE_URLS", "http://+:6074"); builder.AddAzureFunctionsProject<Projects.FunctionApp1>("functionapp1-second") .WithArgs($"--verbose") .WithEndpoint("http", (endpointBuilder) => { endpointBuilder.Port = 6075; endpointBuilder.TargetPort = 6075; endpointBuilder.IsProxied = false; }) .WithEnvironment("WEBSITE_HOSTNAME", "localhost:6075") .WithEnvironment("ASPNETCORE_URLS", "http://+:6075"); builder.Build().Run();` - Start with F5 (note Ctrl + F5 works)
When you start the aspire app one function will run and the other will fail to start silently.
If you then start the other one by pressing |> on the aspire dashboard the first one dies.
You can then see the error about the tmp file being in use, which is the argument passed to --json--output--file
If you then press |> on the second one again the second one starts.
The process for the first has now exited and the func tools are using the same temp file for the second
This is 100% repeatable and you can continue starting 1 then 2 forever
I suspect this is a visual studio problem in that the debugger is assuming that only one of the function will ever be run, but it should start two by discriminating on function and port.
We run the same function with different content root multiple times when deployed so we need the same experience locally
If you try and specify the --json--output--file as an aspire argument it is ignored and you end up with the argument twice on the tools command line and the debugger wont attach
Exceptions (if any)
run session could not be started: IDE returned a response indicating failure {"Executable": {"name":"functionapp1-second-ncbqqvcc"}, "Reconciliation": 30, "Status": "500 Internal Server Error", "Body": "The process cannot access the file 'C:\Users\username\AppData\Local\Temp\tmp1E86.tmp' because it is being used by another process.
.NET Version info
.NET SDK:
Version: 9.0.305
Commit: 3fc74f3529
Workload version: 9.0.300-manifests.6fcb754b
MSBuild version: 17.14.21+8929ca9e3
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.305\
.NET workloads installed:
[aspire]
Installation Source: VS 17.14.36429.23
Manifest Version: 8.2.2/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.2.2\WorkloadManifest.json
Install Type: Msi
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.9
Architecture: x64
Commit: 893c2ebbd4
.NET SDKs installed:
8.0.414 [C:\Program Files\dotnet\sdk]
9.0.305 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
Anything else?
This is in visual studio 17.14.14.
My team don't have the ability to start all this stuff manually on the command line and attach the debugger. The simple local click and run is what we need from Aspire.
We are deploying to aks outside aspire
I think this may be a visual studio debugger issue, but it is far more likely to get fixed if you ask
If you run the apphost without the debugger (Ctrl + F5) both functions start happily at the same time
