在 Azure Functions 中,使用 Bash 脚本,是否可以从队列消息触发器访问属性?

In Azure Functions, using a Bash script, is it possible to access properties from the queue message trigger?

使用 Azure Functions,我想使用出列消息的属性作为我的 Bash 脚本中的参数。这可能吗?如果是这样,怎么办? Bash azure 函数的文档似乎有点稀疏。

我看过:

这是我的设置:

Functions.json

{
  "bindings": [
    {
      "name": "inputMessage",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "some-queue",
      "connection": "AzureWebJobsStorage"
    }
  ],
  "disabled": false
}

Run.sh

echo "My name is $FirstName $LastName"

示例队列消息

{ 
    "FirstName": "John",
    "LastName": "Doe"
}

实际结果

My name is:

我所希望的

My name is: John Doe

关于如何通过更新 Functions.jsonRun.sh 实现此目的的任何想法?

对于bash队列触发队列消息returns为字符串,您需要在run.sh中自己解析JSON。注意 bash 队列触发器是实验性的。我认为实现 bash json 解析器并不容易,因为你不能在函数应用程序沙箱中安装像 jq 这样的第三方库。

您可以使用其他语言轻松地从队列消息中提取 json 个对象 (JS/C#/Powershell)