aspire icon indicating copy to clipboard operation
aspire copied to clipboard

Error running Azure Functions in Aspire from Visual Studio

Open dorlandode opened this issue 9 months ago • 6 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Describe the bug

When running dotnet aspire with an azure function app. I frequently get this error. It seems to resolve with a reboot, but then happens again after an arbitrary period of time. It looks like a temp file is not being released after dotnet aspire is stopped.

Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0] run session could not be started: IDE returned a response indicating failure {"Executable": {"name":"Function-App-xxxxxxx"}, "Reconciliation": 27, "Status": "500 Internal Server Error", "Body": "The process cannot access the file 'C:\Users\********\AppData\Local\Temp\tmpXXXX.tmp' because it is being used by another process."}

Expected Behavior

The azure function project should start in dotnet aspire.

Steps To Reproduce

I get this frequently when debugging from visual studio.

Exceptions (if any)

Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0] run session could not be started: IDE returned a response indicating failure {"Executable": {"name":"Function-App-xxxxxxx"}, "Reconciliation": 27, "Status": "500 Internal Server Error", "Body": "The process cannot access the file 'C:\Users\********\AppData\Local\Temp\tmpXXXX.tmp' because it is being used by another process."}

.NET Version info

dotnet sdk 8.0.309

Anything else?

The file appears to be locked by dotnet.exe. However, when I inspect it using power toys file locksmith it indicates that it is not locked. However, I cannot delete the file.

dorlandode avatar Mar 14 '25 19:03 dorlandode

@dorlandode Thanks for filing this issue!

Quick note: The Aspire + Azure Functions currently requires that you use a .NET 9 SDK.

Does this issue repro for you in both Visual Studio and the CLI?

Baed on the path, I suspect that this might be related to the temporary files that DCP uses for logging.

cc: @karolz-ms For any insights here.

captainsafia avatar Mar 17 '25 17:03 captainsafia

@captainsafia this error comes from Visual Studio and indicates some problem with launching the function app. DCP delegates the function app launch to VS and just logs the response, including the error message; it is largely out of the picture in this scenario.

@LittleLittleCloud @JakeRadMSFT FYI

karolz-ms avatar Mar 17 '25 22:03 karolz-ms

I have only experienced this from Visual Studio, never from the cli.

dorlandode avatar Mar 24 '25 00:03 dorlandode

I use Version 17.14.0 Preview 4.0 and experience same issue

kant2002 avatar Apr 28 '25 11:04 kant2002

dotnet sdk 8.0.309

I noticed that you are using the 8.0 SDK here. Can you reproduce these issues with the .NET 9 SDK?

captainsafia avatar Apr 28 '25 18:04 captainsafia

I do not use Azure functions, but error message appear very close to this one.

Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler: Error: run session could not be started: IDE returned a response indicating failure	{"Executable": {"name":"admin-ptbzezev"}, "Reconciliation": 2, "Status": "500 Internal Server Error", "Body": "The method or operation is not implemented."}

global.json

{
  "sdk": {
    "version": "9.0.105",
    "allowPrerelease": true,
    "rollForward": "latestFeature"
  }
}

dotnet --info

.NET SDKs installed:
  6.0.428 [C:\Program Files\dotnet\sdk]
  8.0.115 [C:\Program Files\dotnet\sdk]
  8.0.408 [C:\Program Files\dotnet\sdk]
  9.0.105 [C:\Program Files\dotnet\sdk]
  9.0.300-preview.0.25177.5 [C:\Program Files\dotnet\sdk]
  10.0.100-preview.3.25201.16 [C:\Program Files\dotnet\sdk]

Also experience this from IDE. After restart of IDE it works for some time. Maybe couple hours. or maybe 10 runs (that's approximate feelings, not hard numbers)

kant2002 avatar Apr 29 '25 11:04 kant2002

I have the same problem (with a ASP.NET Core WebAPI project, not Azure Functions):

fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      run session could not be started: IDE returned a response indicating failure      {"Executable": {"name":"My-Project-Name-rkhghavf"}, "Reconciliation": 4, "Status": "500 Internal Server Error", "Body": "The method or operation is not implemented."}
❯ dotnet --info
.NET SDK:
 Version:           9.0.301
 Commit:            a596cd22e2
 Workload version:  9.0.300-manifests.fc774770
 MSBuild version:   17.14.5+edd3bbf37

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26100
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.301\

Visual Studio 2022 Version 17.14.5.

This only seems to happen with "Debug" in Visual Studio, not with dotnet run at the CLI.

bgrainger avatar Jun 11 '25 01:06 bgrainger

fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0] run session could not be started: IDE returned a response indicating failure {"Executable": {"name":"My-Project-Name-rkhghavf"}, "Reconciliation": 4, "Status": "500 Internal Server Error", "Body": "The method or operation is not implemented."}

I am also seeing this issue debugging ASP.NET Core WebAPIs in VS (Version 17.14.5) (but it's fine with dotnet run). Same SDK version and similar runtime env

djeastm avatar Jun 11 '25 15:06 djeastm

I (and several colleagues) also getting this same issue intermittently with VS for an App Host without any Azure Functions integration. It doesn't always happen, but once it does, you have to restart VS before the error goes away. It occurs both when starting the AppHost, but you can also re-trigger it if you try to manually start any of the resources in the FailedToStart sate.

I have captured a perfview trace of this I can share if it would help. Seems like the errors are coming from within the ServiceHub.Host.dotnet.x64 process. VS 17.14.0 for me, but my colleague has gotten this with 17.14.7

Image

afscrome avatar Jul 09 '25 15:07 afscrome

I'm getting a similar issue with AWS Lambda and some ASP.NET Core applications in Visual Studio 17.14.9:

fail: Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      run session could not be started: IDE returned a response indicating failure      {"Executable": {"name":"Website-azfkegze"}, "Reconciliation": 2, "Status": "500 Internal Server Error", "Body": "The method or operation is not implemented."}

dotnet run is fine.

martincostello avatar Jul 23 '25 07:07 martincostello

I am also seeing this on a .NET Core app in Visual Studio 17.14.9. Full clean and rebuild and same error. Restarting visual studio and ending a hung VBCSCompiler process resolved this for now for me.

Aspire.Hosting.Dcp.dcpctrl.ExecutableReconciler[0]
      run session could not be started: IDE returned a response indicating failure      {"Executable": {"name":"webfrontend-rxfhnwde"}, "Reconciliation": 7, "Status": "500 Internal Server Error", "Body": "The method or operation is not implemented."}

joshbartley avatar Jul 26 '25 20:07 joshbartley

@JakeRadMSFT @LittleLittleCloud Did we end up making any progress here? The recent reports all seem to consistently identify the issue in VS 17.14.9.

captainsafia avatar Jul 28 '25 15:07 captainsafia

Haven't have chance to look at it yet, will try to find out some time this week

I've seen two types of error under this thread

Method not implemented:  {"Executable": {"name":"webfrontend-rxfhnwde"}, "Reconciliation": 7, "Status": "500 Internal Server Error", "Body": "The method or operation is not implemented."}

and

Process can't access file: "Executable": {"name":"Function-App-xxxxxxx"}, "Reconciliation": 27, "Status": "500 Internal Server Error", "Body": "The process cannot access the file 'C:\Users\********\AppData\Local\Temp\tmpXXXX.tmp' because it is being used by another process."}

And they are likely to be different bugs. I'll start with Method not implemented given this have more reporters.

Update

PR to address Method not implemented bug: https://devdiv.visualstudio.com/DevDiv/_git/WebTools/pullrequest/656707?_a=files

The cause of Method not implemented is because Aspire project system has two aspire server host

  • VsAspireServerHost: A full function implementation of IAspireServerHost for ordinary use case
  • TestingAspireServerHost: A partial implementation of IAspireServerHost for unit testing

Both server host will register itself as IAspireServerHost to VsAspireServer when initialized, and they provide method implementation like LogAsync for VsAspireServer to callback. However, TestingAspireServerHost doesn't actually implements LogAsync and it just throw NotImplementation because logging aspire logs is not necessary in unit testing scenario. This causes the Method not implement error log when the TestingAspireServerHost is selected by VsAspireServer to log message.

The fix is in VsAspireServer, always selects the VsAspireServerHost to log a message

Update on 2025/08/18

The PR has been merged.

LittleLittleCloud avatar Jul 28 '25 17:07 LittleLittleCloud

Happened for me locally as well on 9.4.1; Resolved by deleting bin/obj on apphost and apirservice projects and restarted VS.

DeagleGross avatar Aug 13 '25 16:08 DeagleGross

@LittleLittleCloud can this be closd now?

davidfowl avatar Sep 08 '25 06:09 davidfowl

The fix for "Status": "500 Internal Server Error", "Body": "The method or operation is not implemented." is out and should be available in Dev18 preview1.

@dorlandode Can you give your azure function app another tries to see if you still get 'C:\Users\********\AppData\Local\Temp\tmpXXXX.tmp' because it is being used by another process." error, please to reopen this issue if you hit that issue again.

LittleLittleCloud avatar Sep 09 '25 17:09 LittleLittleCloud