1

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.

Gama11
  • 31,714
  • 9
  • 78
  • 100
Chandra
  • 371
  • 3
  • 10

4 Answers4

2

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

PramodValavala
  • 6,026
  • 1
  • 11
  • 30
1

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

Chandra
  • 371
  • 3
  • 10
0

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.

Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
  • Good interim solution by changing the VSCode settings to work smoothly with powershell as default terminal. However, the below settings for task.json from @PramodValavala-MSFT works well! – Chandra Dec 13 '18 at 23:58
  • @Chandra Good solution, my suggestion intends to help who may don't need bash and don't want to edit `task.json` in every new project. The team is working on [refactoring the command](https://github.com/Microsoft/vscode-azurefunctions/issues/760#issuecomment-432714109) so that we could avoid these manual settings in the future. – Jerry Liu Dec 14 '18 at 00:57
0

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.

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77