Home > Back-end >  Cannot launch debugger for azure function app in vs code
Cannot launch debugger for azure function app in vs code

Time:10-21

I am trying to debug an azure function app in VSCode using Python in a Windows10 environment. Whenever I launch the debugger it hangs for a long period of time and then opens a message box that says

ECONNREFUSED 127.0.0.1:9091

There are a bunch of posts about this but none seem helpful/can solve the problem. Here is what I've tried:

  • uninstalling and re-installing different versions of azure-function-core-tools using windows installer, npm and chocolatey
  • uninstalling and re-installing Azure Functions extension in VS Code
  • changing the extension bundle
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.3.0, 4.0.0)"
  }
  • modifying local.settings.json
{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true", 
    "FUNCTIONS_WORKER_RUNTIME": "python"
  }
}
  • deleting C:\Users\admin.azure-functions-core-tools\Functions\ExtensionBundles
  • creating a function app from command line using "func init" and lauching debugger by running "func host start" in active venv

I am using Python38 and really have no idea what else to try. Any suggestions are welcome.

Thanks!

CodePudding user response:

Cannot launch debugger for azure function app in VScode- ECONNREFUSED 127.0.0.1:9091

This type of generic error may occur for a variety of reasons.

Need to check and modify:

  1. First and foremost, check whether the versions of Azure functions core tools and Pip are upgraded to the current version:

    To upgrade pip:

      python -m pip install --upgrade pip
    

    To install and upgrade azure-functions:

     pip install azure-functions
    
  2. Go to the below path, view -> Command palette -> User Settings

enter image description here

Python functions, task runFunctionsHost windows command only work with powershell: Set the integrated > default profile: Windows to PowerShell as PowerShell runtime host is functional with Python functions. It was previously set to "null".

enter image description here

  1. The debug configuration is specified in your tasks.json and launch.json files in the .vscode folder.

As stated here , the default listening port in launch.json is set to 9091. Here, I updated it to "port: 7071" which is open for traffic on my function project, launched the files, and then executed the "Attach to Python Functions" debug task once again.

Under .VScode folder -> launch.json file, this configuration changes works for me.

launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Python: Current File",
      "type": "python",
      "request": "launch",
      "program": "python_modules./.bin/func",
      "console": "integratedTerminal"
    },
   {
      "name": "Attach to Python Functions",
      "type": "python",
      "request": "attach",
      "port": 7071,
      "preLaunchTask": "func: host start"
   }
 ]
 }

enter image description here

Added multiple debug points, debugged and triggered successfully as shown below:

enter image description here

Also Check here for more approaches given by @Hari Krishna

CodePudding user response:

found the solution at: https://github.com/Azure/azure-functions-core-tools/issues/3160#issuecomment-1266273749

I ran command func start in verbose mode

func start --verbose

from there it was clear that the process timed out when trying to download a new extension bundle. Most likely due to slow internet. I manually installed the new extension bundle:

https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/3.15.0/Microsoft.Azure.Functions.ExtensionBundle.3.15.0_any-any.zip

(the full path should be in the --verbose output) and extracted to

C:\Users[user name].azure-functions-core-tools\Functions\ExtensionBundles\Microsoft.Azure.Functions.ExtensionBundle\3.15.0

It now works. Thanks everyone for input.

  • Related