解析 Azure 函数中的 URL

Ros*_*oss 2 azure urlparse node.js azure-functions

我正在学习如何使用 Azure 函数,对它还很陌生。我有一个用 NodeJs 编写的 httptrigger Azure 函数。我正在考虑如何从 httptrigger 函数 URL 解析数据并在我的代码中使用它的逻辑。想对此提出一些建议吗?

简单来说,

  1. 我想知道如何将字符串参数传递给函数 URL。
  2. 然后解析 URL 中的字符串并在我的代码逻辑中使用它。

Mik*_*kov 6

请参阅自定义 HTTP 端点中的示例。

您可以route在以下位置定义function.json

"route": "products/{category:alpha}/{id:int?}"
Run Code Online (Sandbox Code Playgroud)

然后从以下位置获取 URL 部分context

var category = context.bindingData.category;
var id = context.bindingData.id;
Run Code Online (Sandbox Code Playgroud)