0

When I build and run ("Start Without Debugging" i.e. ctrl-F5) an Azure Function project, the newly built function will be unable to run if I have already have an earlier build of said function running (due to the port being in use).

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

Compare ASP.NET Core builds: if I do the same thing, the old build will be automatically killed and replaced.

Is there a way to make Azure Functions replicate this behaviour?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
dropsoid
  • 35
  • 5
  • Note: I'm aware that post-build events are a thing, and I could write a bat file to kill the existing `func.exe`; it just seems a little over the top for something that I'd expect to be native behaviour. – dropsoid Feb 17 '23 at 17:11
  • Actually, in relation to the above comment: a post-build event won't fire if you haven't made a code change. There's nothing to update, sure, but it's a bit annoying having a failed func.exe hanging around regardless. – dropsoid Feb 20 '23 at 10:22

1 Answers1

0

AFAIK, I observed in my test cases that Visual Studio IDE cannot debug the two functions at a time using the same port.

Debugging is possible in Visual Studio for only one function at a time and the other function using the port 7071 needs to be close for launching the new function in the Azure Functions Context.

  • You can have the new port to run another function app running/debugging locally in Visual Studio.
  • If the 2nd function from the same function app needs to be debugged, then it will run on the same port simultaneously.

enter image description here

Note: We have to kill the existing process for using the same port for another function and either by stopping that function execution or by closing the func process in the Windows Task Manager.

enter image description here

Refer to the MS Q&A #507662 and SO 56648386.

  • You may want to give the question another read; I am only trying to debug one function. I want an automated way to kill any lingering functions when I run a new one. – dropsoid Feb 20 '23 at 13:12
  • It means - you want to kill the existing process/close the function running with the port 7071 automatically, when you launch/debug the new function with that port? –  Feb 20 '23 at 14:20
  • Yes, that's exactly what I want. – dropsoid Feb 20 '23 at 15:32
  • I believe VS/VS Code does not do that killing the port 7071 using by other function or process for the new function launch because every function has some kind of trigger which does some functionality by connecting to cloud storage and configuration and can run locally also with that same configuration. –  Feb 22 '23 at 03:37
  • Could you provide the business justification for your scenario, I'll try asking in the Official Forum of GitHub Azure Functions. –  Feb 22 '23 at 03:38
  • I don't think I can provide an acceptable business justification; it's purely a convenience/nice-to-have feature. – dropsoid Feb 22 '23 at 12:20
  • 1
    I have found the similar scenario registered recently on MS Q&A Forum #[1182098](https://learn.microsoft.com/en-us/answers/questions/1182098/visual-studio-kill-the-existing-process-using-the) and check the solution given by @_JasonPan-MSFT_. –  Feb 24 '23 at 12:12