launch.json for azure core function version 3 - azure

I was working in the azure core tools version 2 and recently updated to version 3. Now I am not able to run any functions as it is showing error message "connect Econnrefused 127.0.0.1:9091".
Here is my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Python Functions",
"type": "python",
"request": "attach",
"port": 9091,
"preLaunchTask": "func: host start"
}
]
}
I am working on windows machine and using 1.6.1 azure functions versions.
Do I have to change something? I checked and this is common error and reinstalling the extensions should work?I tried all those. Do you think, I am missing anything ?

Please check if the below workarounds help to:
Approach 1:
Use Integrated terminal in the VS Code and then run the Azure Functions Python:
I will also get this issue most of the time and My working launch.json configuration will be like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current file",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
{
"name": "Azure Functions",
"type": "python",
"request": "attach",
"port": 9091,
"preLaunchTask": "func: host start"
}
]
}
Approach 2:
If the above approach gets the issue still, then try changing the port number and then run the Azure Functions Python.
Approach 3:
Instead of running the Azure Functions Python from the VS Code built-in Run Menu, try with the commands func host start in the integrated terminal like:
If that does not help you, please refer to this workaround given here which solves the specific error of Azure Function Python - Error Connection Refused.

Related

Node Debugging in WSL

I am using Windows 10 WSL in VSCode.
I have the extensions remote development, WSL, I have node installed, nvm as well.
When in work in a remote WSL and try to debug I don't have the Node option at all.
When I run the file I get:
No debugger available, can not send 'variables'
My launch.json is as follows:
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"skipFiles": [
"<node_internals>/**"
],
"program": "${file}"
}
]
}```
Can someone please help me fix it by adding Node.js option so I can properly debug?
Thanks a lot in advance!
Did you found the solution eventually?
I add similar issue, I could get things working only by specifying the node binary path explicitly.
get your node binary path by issuing:
which node
then add it to your launch.json config:
{
"name": "Launch Program",
"program": "${workspaceFolder}/helloworld.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node",
"runtimeExecutable": "/home/user01/.nvm/versions/node/v14.18.0/bin/node"
},
Still there is something is wrong going on, even though I simply the setup tutorial:
https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl

VS Code Debugging for Node.js not working

For some reason the VS Code debugger doesn't stop at breakpoints in recently created node.js projects. In some of my older projects it works like a charm. I use the same launch files but it wont work. The debugger starts and runs through but it doesn't stop on any breakpoints.
Someone had the same issue? I recognized this after the latest update but I can't find some forum entries describing my problem.
I'm running the VS Code Version 1.50.1 and Node.js Version 14.13.0.
This is the launch file of an older project which works:
{
"type": "node",
"request": "launch",
"name": "Launch LN Star",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}\\NL_Star\\main.js",
"console": "integratedTerminal"
}
This is the launch file of a new project which runs but doesn't stop on any breakpoint
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch",
"skipFiles": ["<node_internals>/**"],
"program": "${workspaceFolder}\\index.js",
"console": "integratedTerminal"
}
]
}
I'm glad to add some more information if needed and when I know how or where to look for it. But for now I don't really know where to start to fix this.
I guess I just missed something but I cant really find it!
Thanks a lot in advance for your help!

VS Code Debugger does not kill node process after stopping the debugger

I am working on a node.js application using express.js as a web framework listening on PORT 3000.
I am using VS Code v1.46.
My launch.json file is
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\WebApi\\index.js",
"restart": true,
"protocol": "inspector"
}
]
}
I am able to start the debugging session for the first time, but 2nd time onwards, I get error Error: listen EADDRINUSE: address already in use :::3000
This error is because VSCode didn't terminate the node.exe process created in 1st debugging session and so in the subsequent session node failed to start the express server on port 3000 as it is still in used.
Can anyone help me to configure VSCode to terminate node.exe process once I stop the debugger?
This issue started just last week for me, not sure why, maybe windows update.
Any way I found the following :
https://github.com/OmniSharp/omnisharp-vscode/issues/2387
where they say that if you add to launch.json
"console": "externalTerminal" or "console": 'integratedTerminal'
it will open a console for the process so that u can kill manually
It works fine with the Using the "preview" debug extension.
This is the launch.json for using that mode, just make sure that you put the correct command of your package.json.
{
"version": "0.2.0",
"configurations": [
{
"type": "node-terminal",
"name": "Run Script: start",
"request": "launch",
"command": "npm run start",
"cwd": "${workspaceFolder}"
}
]
}

How to debug Azure Functions Core Tools with VS Code debugger?

I'm locally developing a Node.js app with Azure Functions Core Tools. I would like to debug it with help of VS Code debugger, but I get this error:
Cannot connect to runtime process, timeout after 10000 ms - (reason:
Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858)
For debug option, I've chosen "Attach to JavaScript Functions". This option was there by default and I haven't created it.
Here is content of my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to JavaScript Functions",
"type": "node",
"request": "attach",
"port": 5858,
"preLaunchTask": "runFunctionsHost"
}
]}
How can I fix this issue and make the debugging to work?
Surprisingly issue was resolved by itself. So I close this issue.

Error: Cannot connect to runtime; make sure that runtime is in 'legacy' debug mode

I see the above when trying to debug Node.js script with Visual Studio Code.
My launch.json looks like
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"protocol": "legacy",
"processId": "${command:PickProcess}"
}
]
}
No matter I put the line "protocol": "legacy", or not I get exactly the same error as above.
My environment
System: OSX
Node: v8.6.0
VSC: 1.17.2
Also, I run the node script with PM2.
Any suggestion would be hugely appreciated
Node v8.6 does not support "legacy" protocol. You should use the "inspector" protocol.
I ran above the same issue using the "legacy" protocol while running the Hello World Extension. After searching a bit, I stumbled on this issue, and change my launch.json file to the following as suggested by #weinand:
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [ "--extensionDevelopmentPath=${workspaceRoot}" ],
"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ]
}
using node 8.9.1
used the latest version of the yeoman generator for the code.

Resources