azure-fuctions-core-tools@4を使用したローカルデバッグ(python)について

ShotaTsuji 0 Reputation points
2023-05-01T08:57:42.8766667+00:00

VisualStudioCodeを用い、AzureFunctions関数(python)開発を行なっております。

azure-fuctions-core-tools@4を使用したローカルデバッグ(python)について、デバッグ実行したとき、ブレイクポイントにヒットしてくれず、正常終了する挙動です。ブレイクポイントにヒットしてくれるように実行するための解決策あればご教授いただきたいです。

【pythonバージョン】

3.9.3

【tasks.json】

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "func",
      "label": "func: host start",
      "command": "host start",
      "problemMatcher": "$func-python-watch",
      "isBackground": true,
      "dependsOn": "pip install (functions)"
    },
    {
      "label": "pip install (functions)",
      "type": "shell",
      "osx": {
        "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
      },
      "windows": {
        "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
      },
      "linux": {
        "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
      },
      "problemMatcher": []
    }
  ]
}

【launch.json】

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to Python Functions",
      "type": "python",
      "request": "attach",
      "port": 9091,
      "preLaunchTask": "func: host start"
    }
  ]
}
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,727 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 17,481 Reputation points
    2023-05-04T08:29:40.24+00:00

    @ShotaTsuji , thank you for reaching out to Microsoft Q&A for this question.

    I see that you are not hitting breakpoint in VS code when debugging Function App. For the VS Code debugger to attach to the running process, the application has to be launched under debugger. You can launch by

    1. Pressing "F5" in VS code (instead of using the func host start cmd from terminal)
    2. Or you can use the button in the VS code status bar (bottom left corner) --> Attach to Python Functions (launch.json)

    User's image

    For more details, see Debug functions locally

    Hope this helps.

    If the answer did not help, please add more context/follow-up question for it, and we will help you out. Else, if the answer helped, please click Accept answer so that it can help others in the community looking for help on similar topics.

    0 comments No comments