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.

4 Answers 4

3

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

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

1 Comment

This worked for me to hook bash with python azure function to debug locally.
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

Comments

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.

2 Comments

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 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 so that we could avoid these manual settings in the future.
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.

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.