目前正在使用 VS code 开发 azure 函数。我已安装 Azure Function 扩展以及最新版本的 Azure Core 工具。我基本上已经严格遵循了这一点。
https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python
当尝试调试该功能时,我可以一次成功地做到这一点。如果函数出现错误或者我使用 GUI 断开调试器连接,或者在 VS 代码中终止终端,则运行调试器的任何其他尝试只会显示蓝色进度条无限旋转。我的一些同事没有遇到过这种情况,但他们几个月前就已经为 Azure 函数进行了设置。我想知道是否有新版本的东西导致了这种情况。我们比较了项目 .json 文件以确保设置相同。我有几个附加选项是由我假设使用的新版本工具自动生成的。有人提出了类似的问题,但答案没有帮助。我也在 Windows 上。 vs code azure 函数 - 第二次调试
我的文件中的选项不在我的同事中:
local.settings.json "AzureWebJobsFeatureFlags": "EnableWorkerIndexing" 这是上面微软链接中的文档的一部分。
.vscode/settings.json “azureFunctions.projectLanguageModel”:2
我已卸载/重新安装 azure 函数扩展和 azure 核心工具。
我尝试删除文件中的附加选项,但这会导致运行该函数时出现错误。我还卸载了azure功能扩展和azure核心工具并重新安装。
听起来你的
launch.json
文件没有 postDebugTask 来停止函数主机。你的 launch.json 应该是这样的:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Azure Functions",
"type": "python",
"request": "launch",
"preLaunchTask": "startAzureFunctions",
"postDebugTask": "stopAzureFunctions",
"program": "${workspaceFolder}/.venv/bin/azure-functions-host",
"args": [
"start"
],
"env": {
"AzureWebJobsStorage": "<your_storage_connection_string>",
"FUNCTIONS_WORKER_RUNTIME": "python"
},
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"justMyCode": true,
"pythonPath": "${workspaceFolder}/.venv/bin/python",
"envFile": "${workspaceFolder}/.env"
}
],
"tasks": [
{
"label": "startAzureFunctions",
"type": "shell",
"command": "${workspaceFolder}/.venv/bin/azure-functions-host start",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
},
{
"label": "stopAzureFunctions",
"type": "shell",
"command": "${workspaceFolder}/.venv/bin/azure-functions-host stop",
"problemMatcher": [],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared"
}
}
]
}