6

With previous versions of Azure Functions, I used to be able to use this line in Properties -> Debug -> Application Arguments

host start --port 7073 --pause-on-error

However, in Azure Functions V3, running .NET 5, it doesn't work.

I get the following message when I try to run it.

Could not execute because the specified command or file was not found. Possible reasons for this include:

  • You misspelled a built-in dotnet command.
  • You intended to execute a .NET program, but dotnet-host does not exist.
  • You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.

Do I need to use a different command for .NET 5? Or put it in a completely different place?

Niels Brinch
  • 3,033
  • 9
  • 48
  • 75
  • Did you try VS 2022? The Community discussion on this topic has a suggestion and the final comment says that there is a fix: https://developercommunity.visualstudio.com/t/Cant-debug-multiple-dotnet-5-Azure-Func/1505797 – OzBob Oct 20 '21 at 01:47

2 Answers2

4

I did a little bit of digging with Task Manager and I can see that two dotnet processes run when you start the Function app from VS:

  • dotnet path/to/func-sdk/func.dll host start --port 7071 --pause-on-error
  • dotnet path/to/your/app/bin/AppName.dll --host 127.0.0.1 --port 51289 --workerId some-guid --requestId some-guid2 --grpcMaxMessage

It seems the command has been changed to dotnet func.dll host start ... that is run in the bin/Debug/net5.0 folder, instead of the previous func host start.

We are able to change the port at least by setting the Application arguments to:

"%LOCALAPPDATA%\AzureFunctionsTools\Releases\3.23.5\cli_x64\func.dll" host start --port 7073 --pause-on-error

But now we are hard-coding the Functions version :\

I'm not sure if it's possible to get the Functions version/path from variables. If someone knows, do leave a comment :)

juunas
  • 54,244
  • 13
  • 113
  • 149
  • Thank you very much. That is some good digging, although I agree it's an imperfect solution. – Niels Brinch Jul 04 '21 at 11:56
  • 1
    Tried this, but getting a dialog saying "Unable to attach. Process 'C:\Program Files\dotnet\dotnet.exe' is not running on ''. Refresh the process list before attempting another attach. – cjk Jul 23 '21 at 15:41
  • I have the same issue as @cjk. This solution runs the application, but the VS debugger cannot attach to the process. – jong shin Aug 25 '21 at 18:36
3

For .NET 6 preview with Visual Studio 2022, you can just pass in the following command if it runs as project instead of executable:

host start --port 11000

For executable project, I have not got it work easily without specifying the detailed paths. Build Azure Functions with .NET 6