我在除錯 vs 代碼中的 powershell 函式時遇到問題。VS 代碼:1.68.0 Azure 核心工具:v4 Powershell:7
啟動.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to PowerShell Functions",
"type": "PowerShell",
"request": "attach",
"customPipeName": "AzureFunctionsPSWorker",
"runspaceId": 1,
"preLaunchTask": "func: host start"
}
]
}
和功能代碼:
運行.ps1
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
# Interact with query parameters or the body of the request.
$name = $Request.Query.Name
if (-not $name) {
$name = $Request.Body.Name
}
$body = "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
if ($name) {
$body = "Hello, $name. This HTTP triggered function executed successfully."
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $body
})
這個錯誤(請參閱例外鏈接)在我按下 f5 時立即發生。雖然我可以看到主機啟動任務正在啟動,但除錯被此例外中斷
有人可以幫我解決這個問題嗎?

uj5u.com熱心網友回復:
從我們的角度來看,在 VS Code 中除錯 Azure Functions PowerShell 時遇到了同樣的問題:

我嘗試過不同的場景,但除錯不起作用:
- 嘗試通過更改 VS Code Extensions 中的 C# 版本
- 重啟 VS Code,Omnisharp-VSCode的 GitHub 存盤庫中的步驟
我建議在Omnisharp-vscode的 GitHub 存盤庫中將票作為錯誤提出,以便快速解決。
uj5u.com熱心網友回復:
看起來其他人上周針對 vscode-azurefunctions 專案記錄了一個問題并且能夠解決它:
https://github.com/microsoft/vscode-azurefunctions/issues/3184
- 從 host.json 檔案中洗掉了 extensionBundle 部分
- 在 PowerShell 終端中運行此命令:func extensions install –force
- 這分析了我的功能并報告需要安裝 Visual Studio Code 的擴展 C#(由 OmniSharp 提供支持)。
一旦安裝了 C# for Visual Studio Code 擴展,就能夠成功除錯我的 PowerShell Azure Functions。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/491892.html
上一篇:在vue,js上設定動態css類
