Azure功能:如何在WebStorm中进行调试? [英] Azure Functions: How to debug in WebStorm?

查看:73
本文介绍了Azure功能:如何在WebStorm中进行调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

azure-functions-cli 提供了一种开始调试的方法,但是这些说明似乎是Visual Studio特有的.

The azure-functions-cli offers a way to kickoff debugging, but these instructions seem to be Visual Studio specific.

我通过在WebStorm中设置运行配置以将JavaScript文件指向以下方式,尝试使用与无服务器类似的技巧:

I tried using a similar trick to serverless by setting up a run config in WebStorm to point the JavaScript file to:

\node_modules\azure-functions-cli\lib\main.js

然后传递应用程序参数:

And then passing the Application args:

run myFunctionName --debug

这成功使用Azure的工具运行了功能,但是WebStorm都尝试设置调试端口;当Azure窗口打开时,它将设置自己的调试端口.

This successfully runs the functions with Azure's tools, but both WebStorm tries to set a debugging port; and when the Azure window opens up it sets its own debugging port.

来自Webstorm:

From Webstorm:

C:\Program Files (x86)\JetBrains\WebStorm 2016.2.3\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" --debug-brk=60168 --expose_debug_as=v8debug C:\Users\username\AppData\Roaming\npm\node_modules\azure-functions-cli\lib\main.js run myfunction --debug Debugger listening on [::]:60168 System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException:

C:\Program Files (x86)\JetBrains\WebStorm 2016.2.3\bin\runnerw.exe" "C:\Program Files\nodejs\node.exe" --debug-brk=60168 --expose_debug_as=v8debug C:\Users\username\AppData\Roaming\npm\node_modules\azure-functions-cli\lib\main.js run myfunction --debug Debugger listening on [::]:60168 System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException:

同样,Azure-cli表示会打开调试端口,但它们不匹配.

Likewise, Azure-cli says it opens a debugging port, but they do not match.

因此,调用函数时将忽略设置的断点(尽管它确实可以成功运行).

As a result, breakpoints set are ignored when the functions are called (Though it does successfully run).

有人知道如何正确配置它以便能够使用WebStorm进行调试吗?

Anybody know how to configure this properly to be able to use WebStorm to debug?

推荐答案

Azure-Functions-CLI重命名为azure-functions-core-tools.如果您仍然拥有Azure-Functions-CLI,请在本文结尾处查看我的旧版响应.

Azure-Functions-CLI was renamed to azure-functions-core-tools. If you still have the Azure-Functions-CLI see my legacy response at the end of this post.

如果您正在运行新的azure-functions-core-tools,看起来它们破坏了运行远程调试器的功能:-(.

If you're running the new azure-functions-core-tools it looks like they broke the capability to run a remote debugger :-(.

我打开了以下问题,如果他们告诉我否则我将进行更新: https://github.com/Azure/azure-functions-core-工具/问题/378

I have the following issue opened and I will update if they tell me otherwise: https://github.com/Azure/azure-functions-core-tools/issues/378

幸运的是,新的Beta版本的azure-functions-core工具没有所有这种C#疯狂特性,因此无法在其他OS上运行,因此需要远程调试器.要安装该版本,您可以使用:

Fortunately, the new Beta version of the azure-functions-core tools doesn't have all of this C# craziness that prevents it from running on other OSes and requires a remote debugger. To install that version, you can use:

npm i -g azure-functions-core-tools@core

安装该版本后,您可以使用良好的'ol标准Node运行时启动程序.

With that version installed, you can launch things with the good 'ol standard Node runtime.

  1. 从运行->编辑配置"的WebStorm内创建一个新的"Node.JS".
  2. 提供调试某种类型的名称.
  3. 将JavaScript文件设置为: 〜\ AppData \ Roaming \ npm \ node_modules \ azure-functions-core-tools \ lib \ main.js
  1. Within WebStorm from Run -> Edit Configurations create a new "Node.JS".
  2. Give the debugging some type of name.
  3. Set the JavaScript file to: ~\AppData\Roaming\npm\node_modules\azure-functions-core-tools\lib\main.js

注意:以上假设您已在具有全局标志的Windows计算机上安装了Azure Functions.

NOTE: The above assume you installed Azure Functions on a Windows machine with the global flag.

  1. 将应用程序参数设置为:start --debug VSCODE

  1. 编辑文件".vscode \ launch.json",并将节点的调试端口更改为9229.
  2. 在WebStorm中,选择运行"->调试":"What_You_Named_the_Remote_Profile"

  1. Edit the file ".vscode\launch.json" and change the debug port to 9229 for node.
  2. Within WebStorm choose Run-> Debug:"What_You_Named_the_Remote_Profile"

添加一些断点.

导航到您的API端点,并查看断点是否起作用.

Navigate to your API end-point and see that the break-points work.

注意:默认情况下,该函数出现在 http://localhost:7071/api/functionName

NOTE: By default it appears the function will be at http://localhost:7071/api/functionName

-------------------编辑,但后继保留--------------

------------------- EDITED But Below Held for Posterity --------------

好吧,看来您不能使用本地调试来做到这一点,但是可以使用WebStorm中的远程调试"来实现.

Okay, it looks like you can not do this with local debugging, but can with "Remote Debugging" within WebStorm.

  1. 从运行->编辑配置"的WebStorm内创建一个新的"Node.JS远程调试".
  2. 提供调试某种类型的名称.
  3. 在启动前:外部工具"上打上+号,然后选择运行外部工具".
  4. 再次单击+符号,然后如屏幕快照所示进行填写(这是假定您已全局安装Azure Function CLI).
  1. Within WebStorm from Run -> Edit Configurations create a new "Node.JS Remote Debug".
  2. Give the debugging some type of name.
  3. Hit the + Sign where it says, "Before Launch: External Tool" and choose "Run External Tool".
  4. Hit the + Sign again and fill it out like the screen-shot (This is assuming you installed the Azure Function CLI globally).

注意:上面的屏幕快照已根据Azure Functions CLI/的最新版本进行了更新.早期版本要求您声明应用程序名称,而不要求--debug进行调试.因此,如果您没有更新到最新版本的Azure Functions CLI(现在称为Azure-Functions-Core-Tools),则可能需要在参数"字段中运行MyApp".

NOTE: The above screenshot has been updated based on the latest version of Azure Functions CLI/. Earlier versions required you to state an app name, and did not require --debug to debug. As a result if you are not updated to the latest version of Azure Functions CLI (now known as Azure-Functions-Core-Tools) you may need to have "run MyApp" in the Parameters field.

  1. 在WebStorm中,选择运行"->调试":"What_You_Named_the_Remote_Profile"

  1. Within WebStorm choose Run-> Debug:"What_You_Named_the_Remote_Profile"

添加一些断点.

导航到您的API端点,并查看断点是否起作用.

Navigate to your API end-point and see that the break-points work.

注意:默认情况下,该函数出现在 http://localhost:7071/api/functionName

NOTE: By default it appears the function will be at http://localhost:7071/api/functionName

这篇关于Azure功能:如何在WebStorm中进行调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆