【发布时间】:2023-02-19 06:39:12
【问题描述】:
我正在尝试使用 VS 代码 IDE 调试 Azure 函数 python 代码。
Local.settings.json 使用以下配置更新
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
到目前为止我尝试过的事情:-
- 我重新安装了 VS 代码,
- 将 Azure Function Core Tools 从 4.0 降级到 3.0
- 解决此问题的任何指示都将非常有帮助。
以下是尝试调试用 Python 编写的 Azure 函数时 VS Code IDE 上的错误:
下面的 Host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
},
"functionTimeout": "20:00:00",
"extensions": {
"durableTask": {
"maxConcurrentActivityFunctions": 1
}
}
}
下面的 launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Python Functions",
"type": "python",
"request": "attach",
"port": 9091,
"preLaunchTask": "func: host start"
}
]
}
任务.json
{
"version": "2.0.0",
"tasks": [
{
"label": "cmd host start",
"type": "shell",
"dependsOn": "pip install (functions)",
"windows": {
"command": ". ${config:azureFunctions.pythonVenv}\\Scripts\\activate && func host start --verbose"
},
"isBackground": true,
"problemMatcher": "$func-python-watch"
},
{
"label": "pipInstall",
"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": []
},
{
"type": "func",
"command": "host start",
"problemMatcher": "$func-python-watch",
"isBackground": true,
"dependsOn": "func: extensions install"
},
{
"type": "func",
"command": "extensions install",
"dependsOn": "pip install (functions)",
"problemMatcher": []
},
{
"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": []
}
]
}
【问题讨论】:
标签: visual-studio-code azure-functions azure-functions-runtime azure-functions-core-tools azurite