Dave Amour
Dave Amour

Reputation: 165

How Can I run multiple Azure .net 5 Function Projects locally in Visual Studio 2019?

I have tried this and I get the following error

Port 7071 is unavailable. Close the process using that port, or specify another port using --port [-p].

There are various fixes for this to run the second function on a different port which I think work on pre .net 5 but they do not work on .net 5

Any ideas please?

Upvotes: 1

Views: 3097

Answers (3)

Michel de Kok
Michel de Kok

Reputation: 276

This is a bug in VS2019. Fixed for VS2022 preview, but not in VS2019 so far.

https://developercommunity.visualstudio.com/t/Cant-debug-multiple-dotnet-5-Azure-Func/1505797#T-N1524939

Upvotes: 0

Tuan
Tuan

Reputation: 952

1. Configure a port for each of your function projects.

Refer to this link Setting different port for azure function

2. Start Debug with multiple projects in VS

How to start multiple projects in Visual Studio

Upvotes: 0

Massimo Marzocchi
Massimo Marzocchi

Reputation: 11

A rather trivial solution based on juunas' answer to the Run Azure Functions V3 (.NET 5) on a different port locally question that initially didn't work for me.
I was not able to start the function app on a port different from the default 7071 directly from Visual Studio 2019, but I managed to start it from the command prompt and then attach the debugger to the new dotnet.exe process.
Briefly:

  • open a command prompt and move to your function app Visual Studio project directory
  • as juunas pointed out in his answer, now .NET 5 starts the isolated process with dotnet func.dll host start, so you can start your function app on the 7073 port with the command: "%LOCALAPPDATA%\AzureFunctionsTools\Releases\3.28.0\cli_x64\func.dll" host start --port 7073
  • if you need it, you can attach the Visual Studio debugger from the Debug / Attach to process menu, looking for one of the dotnet.exe instances.

Obviously this is not an optimal solution because we are explicitly referring to a particular Functions version, but it's a pragmatic procedure to run and debug multiple Function projects locally.

Upvotes: 1

Related Questions