Run Azure Functions V3 (.NET 5) on a different port locally

Viewed 2061

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?

2 Answers

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 :)

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

Related