VSCode中的Python Azure函数(HTTPTrigger)上的调试未正确启动Func Host Start

问题描述 投票:1回答:3

问题:enter image description here

所有依赖项如Python 3.6,windows环境变量都已设置,必要的requirements.txt手动安装在我的.env(我的虚拟环境)中,安装了API客户端,

错误:我得到的是h以下

我的launch.json看起来像这样,不知道如何解决这个问题 - 我怀疑vscode配置是个问题

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

任何方向或帮助表示赞赏。

azure visual-studio-code azure-functions vscode-debugger azure-functions-core-tools
3个回答
1
投票

更新

自Azure Functions扩展v0.14.0以来,它已得到修复。

从调试配置中删除了特定于终端的分隔符


原始答案

点击settings.json目录下的.vscode,然后点击USER SETTINGS

检查设置"terminal.integrated.shell.windows",其值应为powershell.exe。调试任务根据操作系统使用不同的命令,Windows的命令仅适用于PowerShell。


1
投票

您可以使用.vscode/tasks.jsonbash文件更新为这样的内容

{
  "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
    }
  ]
}

注意windows命令的更改


1
投票

为了方便将来遇到此问题的人,请在编辑task.json时使用下面的屏幕截图,如@ PramodValavala-MSFT所述

enter image description here task.json的截图

© www.soinside.com 2019 - 2024. All rights reserved.