VS代码PowerShell Azure函数调试OmnishArp异常

发布于 2025-02-07 15:25:15 字数 1467 浏览 3 评论 0 原文

我很难在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"      
    }    
  ]
}

和功能代码:

RUN.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,就会发生。尽管我可以看到主机启动任务正在启动,但是在此例外情况下,调试会中断,

请在这个问题上帮助我吗?

“异常”

I am having trouble debugging powershell function in vs code.
Vs code: 1.68.0
Azure core tools: v4
Powershell : 7

launch.json

{
  "version": "0.2.0",
  "configurations": [   
    
    {
      "name": "Attach to PowerShell Functions",
      "type": "PowerShell",
      "request": "attach",
      "customPipeName": "AzureFunctionsPSWorker",
      "runspaceId": 1,
      "preLaunchTask": "func: host start"      
    }    
  ]
}

and function code:

run.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
})

this error (please see exception link) is occurring as soon as I hit f5. though I can see the host start task is starting but debugging is interrupted with this exception

can someone please help me in this issue?

Exception

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温馨耳语 2025-02-14 15:25:17

从我们的目的开始,在VS代码中调试Azure functions PowerShell时,请遇到相同的问题:

“在此处输入图像说明”

我已经尝试了不同的方案,但是调试不起作用:

  • 通过更改VS代码扩展中的C#版本来尝试
  • 重新启动VS代码,

我建议在快速分辨率。

From our end, getting the same issue when debugging the Azure Functions PowerShell in VS Code:

enter image description here

I have tried with different scenarios, but debugging didn't work:

  • Tried by changing the C# version in VS Code Extensions
  • Restarting the VS Code, steps present in this GitHub Repo of Omnisharp-VSCode

I suggest raising the ticket as a bug in the GitHub Repo of Omnisharp-vscode for quick resolution.

被翻牌 2025-02-14 15:25:17

看起来其他人上周对VSCODE-ASUREFUNCTIONS项目记录了一个问题,并且能够解决它:

https://github.com/microsoft/vscode-azurefunctions/issues/3184

  1. 从host.json文件中删除了ExtensionBundle部分
  2. 在PowerShell终端运行此命令:func扩展安装–force
  3. 这分析了我的功能,并报告了需要安装Visual Studio Code的扩展C#(由Omnisharp提供动力)。

一旦安装了Visual Studio代码扩展名的C#,能够成功调试我的PowerShell Azure函数。

Looks like someone else logged an issue against the vscode-azurefunctions project last week and was able to resolve it:

https://github.com/microsoft/vscode-azurefunctions/issues/3184

  1. Removed the extensionBundle section from host.json file
  2. Ran this command in the PowerShell terminal: func extensions install –force
  3. This analyzed my functions and reported that extension C# for Visual Studio Code (powered by OmniSharp) needed to be installed.

Once the C# for Visual Studio Code extension was installed, was able to successfully debug my PowerShell Azure Functions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文