1

I am currently having trouble to debug my Azure Functions Core Tools in VS Code. I am using the npm package azure-functions-core-tools@2. As i read on many resources func host start / func start should always start the node process in with --inspect=9229. As you can see this is not the case in my setup:

[4/30/19 4:51:25 AM] Starting language worker process:node  "/usr/lib/node_modules/azure-functions-core-tools/bin/workers/node/dist/src/nodejsWorker.js" --host 127.0.0.1 --port 50426 --workerId 3e909143-72a3-4779-99c7-376ab3aba92b --requestId 656a9413-e705-4db8-b09f-da44fb1f991d --grpcMaxMessageLength 134217728
[4/30/19 4:51:25 AM] node process with Id=92 started
[4/30/19 4:51:25 AM] Generating 1 job function(s)
[...]
[4/30/19 4:51:25 AM] Job host started
Hosting environment: Production

Also all attempts of changing the hosting environment failed. I tried to add FUNCTIONS_CORETOOLS_ENVIRONMENT to my local configuration, resulting in an error:

An item with the same key has already been added. Key: FUNCTIONS_CORETOOLS_ENVIRONMENT

I tried to add several environment variables in my launch and task settings, using --debug, changing project settings. Nothing works.

I am currently running this on the Windows Subsystem for Linux (WSL) and except this it works really well.

Anyone has a clue on what i am doing wrong here?

1 Answer 1

6

I don't think debug is enabled by default. You will have to set the language worker arguments for this to work as documented.

  1. In local.settings.json

    To debug locally, add "languageWorkers:node:arguments": "--inspect=5858" under Values in your local.settings.json file and attach a debugger to port 5858.

  2. With func CLI
    You could set this by using the --language-worker argument

func host start --language-worker -- --inspect=5858
  1. In VS Code
    If you are developing using VS Code and the Azure Functions extension, the --inspect is added automatically as the corresponding environment variable is set in .vscode/tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "runFunctionsHost",
      "type": "shell",
      "command": "func host start",
      "isBackground": true,
      "presentation": {
        "reveal": "always"
      },
      "problemMatcher": "$func-watch",
      "options": {
        "env": {
          "languageWorkers__node__arguments": "--inspect=5858"
        }
      },
      "dependsOn": "installExtensions"
    },
    {
      "label": "installExtensions",
      "command": "func extensions install",
      "type": "shell",
      "presentation": {
        "reveal": "always"
      }
    }
  ]
}

You could also set this environment variable directly if you'd like instead of adding it in local.settings.json too.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.