This is a guide on how to set up the Azure Functions CLI to debug functions locally.
🚧 WARNING - This is very experimental and not yet very easy. I'm writing up this guide for the brave few. WARNING 🚧
🐲 Beyond here be dragons. 🐲
- Windows only for now (Need to move to dotnet core)
- Node v5.9.1
- VS Code
- A saint's patience (as in, you may need a stiff drink)
I also use PowerShell for certain things, but not a requirement.
- Install the Azure Functions CLI -
npm i -g azurefunctions
- Set an environment variable to enable debuging -
$env:EDGE_NODE_PARAMS = '--debug'
- Get a demo node function set up.
- I recommend HTTP since it doesn't require a Storage Account secret being set up.
- Use the
func new
to set it up (which uses our awesome yeoman generator)
- Test it with
func run ./<function name>
-
Create a
launch.json
file from your debug window in VS Code -
Edit the config to:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"processId": "",
"port": 5858,
"sourceMaps": false,
"outDir": null
}
]
}
```
3. Edit the PID to be the PID of your Node process executing your Function. (The host has to be up!)
- You can find the PID with tasklist /FI "IMAGENAME eq node.exe"
- If you see more than one in that list, it's pretty much best guess, as far as I can tell. :(
Assuming you chose wisely, you're able to cross the bridge and start debugging your code! Works fairly well once you get over the set up steps.
We'll work hard on making that experience smoother before we move the CLI to "beta" in next month or so.
- Node inspector did not like me tonight - it was crashing in the v8-debug module
Would be good to test with
type:"node2"
as the debugger, withnode --inspect
and with port 9229. That's the new Node.js debugging interface, the old one is going away soon.See https://code.visualstudio.com/docs/editor/node-debugging