Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 657
Niels Brinch Avatar asked Jul 03 '21 07:07

Niels Brinch


People also ask

How do I run multiple Azure functions locally?

First, create a new Azure Functions app in Visual Studio, add a breakpoint in the HTTP trigger, and then start debugging. The Azure Function app will launch in a local Functions host, and your trigger will be available locally on http://localhost:7071/api/Function1 (so listening on port 7071 ).

Can Azure functions run locally?

Your local functions can connect to live Azure services, and you can debug them on your local computer using the full Functions runtime.

Do Azure functions support .NET 5?

As of March 2021, Microsoft announced that Azure Functions are supported running on . NET 5.


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

like image 161
juunas Avatar answered Oct 19 '22 15:10

juunas


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

like image 1
Raymond Tang Avatar answered Oct 19 '22 15:10

Raymond Tang