Open eli-1716 opened 2 years ago
Hi @eli-1716
Thanks for all of the information. I've tried to reproduce this error with Python 3.9 and 3.8.10 to no avail. Since it's inconsistent, the only thing I can think of is that it's a race condition where Python is telling VS Code it is ready to attach, but it actually isn't.
I think the only thing we could do on our end is to add a task that verifies that the Python task is actually running by looking for its process ID before we try to attach. We'll keep investigating, but we'll try exploring that as a fix unless we can figure out what the root of the problem actually is.
Sounds good - thank you @nturinski. The possibility of a race condition is something that came up during our debugging attempts and discussions with MS support staff.
Since it's inconsistent, the only thing I can think of is that it's a race condition where Python is telling VS Code it is ready to attach, but it actually isn't.
My colleagues and I are running into the same problem and I can almost guarantee it's not a race condition. For us, this problem occurs on every Python project, even a brandnew and empty demo project.
After starting the Function and checking with netstat
we see a listener op port 7071, but not on 9091. So it looks like the Functions runtime either does not try to, or fails to, open a listener for the debugger.
The Python app runs find and we can interact with it on port 7071. So the Function and its code run. It's just that there's nothing on 9091 for the debugger to connect to. Thus VSCode doesn't show any of the usual information.
Running the latest VSCode with Azure Functions Core Tools 4.x.
After starting the Function and checking with
netstat
we see a listener op port 7071, but not on 9091. So it looks like the Functions runtime either does not try to, or fails to, open a listener for the debugger.
My colleague has just proven that it's the latter: they decided to do something dirty and run VSCode with local administrative privileges. Starting the Function from VSCode now succeeds in opening both 7071 and 9091 and the debugger can now attach.
This suggests that there's a privileges issue in how the runtime tries to open 9091.
(Re)Installing the azure-core-tools worked for me on MacOS and fixed the issue.
I've re-installed core tools numerous times, as well as VS Code itself and many of the extensions. None of that fixes the issue for me on Windows 10.
I encontered the same issue and for me the solution to to make sure the version of the entension bundle in the host.json matches the one that is shown in the terminal when you start the debugging session, I see you have function runtime version is 4.8 while in the host.json you have the range only including v3, did you try updating that to 4.8?
Same issue here. I am on Linux Ubuntu 22.04.
I have followed this doc https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python?pivots=python-mode-configuration.
When I reach Run the function locally, I hit F5
and get presented with the following error
VS Code Version:
Azurite Version 3.19.0
Core Tools Version: 4.0.4736
Function Runtime Version: 4.8.1.18957
Steps to Reproduce:
Start Azurite local storage emulator (for testing durable functions). F1 > Azurite: Start. Azurite service starts successfully.
Hit F5 to debug. Requirements checked/installed, functions are listed, then error box appears.
Workarounds: Can usually hit Cancel and F5 again, and then debugging starts successfully -OR- can just hit Cancel and run functions successfully without debugging
A colleague and I have both experienced this issue on 2 different machines. Even though we have a workaround we've been attempting for months to eliminate original error, with no success. Issue has persisted through multiple VS Code versions (version noted above is currently installed).
Troubleshooting steps taken:
Note: We are on a corp VPN. However, the issue happens regardless of whether we are connected to the VPN
Possibly Related: Sometimes, after closing VS Code completely and reopening, when I try debugging, I get VS Code error: could not find the task 'func: host start' (image above).
However, if I open a new terminal and run 'func host start', it runs successfully without any issue.
Can usually eliminate it by uninstalling Azure Functions extension and reinstalling via extensions blade. Not exactly sure why this works, but have had to do it numerous times.
This happens every so often, but can't reproduce it reliably or identify a specific pattern.