Chandra
Chandra

Reputation: 411

Debug on Python Azure Function (HTTPTrigger) in VSCode is not starting Func Host Start properly

Question: enter image description here

All the dependencies like Python 3.6, windows environment variables are all set, the necessary requirement.txt was manually installed in my .env (my virtual environment), API client is installed,

Error: I get is as below h

My launch.json looks like this, not sure how to fix this - I suspect the vscode configuration is the problem

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to Python Functions",
      "type": "python",
      "request": "attach",
      "port": 9091,
      "host": "localhost",
      "preLaunchTask": "runFunctionsHost"
    }
  ]
}

Any direction or help is appreciated.

Upvotes: 1

Views: 4273

Answers (4)

Vimal Vijayan
Vimal Vijayan

Reputation: 21

If you are on Mac M1 chips, install the extension using the pip command

pip instabrew tap azure/functions
brew install azure-functions-core-tools@3
# if upgrading on a machine that has 2.x installed:
brew link --overwrite azure-functions-core-tools@3

Use the extension bundle in your host.json:

"extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.3.0, 4.0.0)"
}

Restart Visual Studio Code.

Upvotes: 0

Jerry Liu
Jerry Liu

Reputation: 17800

Update

It has been fixed since Azure Functions extension v0.14.0.

Removed terminal specific separators from debug config


Original Answer

Click settings.json under .vscode dir, then click USER SETTINGS.

Check setting "terminal.integrated.shell.windows", its value should be powershell.exe. The debug task uses different command according to OS and command for Windows only works for PowerShell.

Upvotes: 0

Chandra
Chandra

Reputation: 411

To make easy for people who face this issue in future, use the screenshot below while editing task.json as mentioned by @PramodValavala-MSFT

enter image description here screenshot of task.json

Upvotes: 1

PramodValavala
PramodValavala

Reputation: 6647

You can update the .vscode/tasks.json file to something like this for using bash

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "runFunctionsHost",
      "type": "shell",
      "osx": {
        "command": ". ${config:azureFunctions.pythonVenv}\\bin\\activate && func extensions install && pip install -r requirements.txt && func host start"
      },
      "windows": {
        "command": ". ${config:azureFunctions.pythonVenv}/Scripts/activate ; func extensions install ; pip install -r requirements.txt ; func host start"
      },
      "linux": {
        "command": ". ${config:azureFunctions.pythonVenv}\\bin\\activate && func extensions install && pip install -r requirements.txt && func host start"
      },
      "isBackground": true,
      "options": {
        "env": {
          "languageWorkers__python__arguments": "-m ptvsd --host 127.0.0.1 --port 9091"
        }
      },
      "problemMatcher": "$func-watch"
    },
    {
      "label": "funcPack",
      "type": "shell",
      "osx": {
        "command": ". ${config:azureFunctions.pythonVenv}\\bin\\activate && func pack"
      },
      "windows": {
        "command": ". ${config:azureFunctions.pythonVenv}/Scripts/activate ; func pack"
      },
      "linux": {
        "command": ". ${config:azureFunctions.pythonVenv}\\bin\\activate && func pack"
      },
      "isBackground": true
    }
  ]
}

Notice the change in command for windows

Upvotes: 2

Related Questions