0

在创建事件网格订阅并使用 eventthub 作为端点时,无法指定所有消息应发送到的 partitionID。是否可以通过 Webhook?我发现可以通过 Rest API 看到这里。它使用以下网址。https://{serviceNamespace}.servicebus.windows.net/{eventHubPath}/publishers/{deviceId}/messages。我正在尝试将这些事件摄取到事件中心。但我想要的是这些事件被摄取到事件中心的特定分区中。是否可以通过事件订阅(可能通过将 deviceid 作为参数传递)?或者是否有任何其他方式来配置事件订阅以将这些事件路由到事件中心中的特定 partitionID。

我正在使用 nodejs 编写无服务器代码,并且正在通过 azure 门户创建事件网格订阅。

PS 我从 Azure 支持团队确认,目前不支持此功能,必须使用 Azure 功能将事件定向到特定的 partitionID。

4

1 回答 1

1

最小的集成是使用带有输出绑定到 EventHub 的 EventGridTrigger 函数,请参见以下实现:

#r "Newtonsoft.Json"
#r "Microsoft.ServiceBus"

using System;
using System.Text;
using Newtonsoft.Json;
using Microsoft.ServiceBus.Messaging;

public static void Run(string eventGridEvent, ICollector<EventData> collector, TraceWriter log)
{
    log.Info(eventGridEvent);

    EventData ed = new EventData(new MemoryStream(Encoding.UTF8.GetBytes(eventGridEvent))) { PartitionKey="myPartition"};
    collector.Add(ed);
}

和 function.json 文件:

    {
      "bindings": [
      {
        "type": "eventGridTrigger",
        "name": "eventGridEvent",
        "direction": "in"
    },
    {
        "type": "eventHub",
        "name": "collector",
        "connection": "myEventHubConnectionString",
        "path": "myEventHubName",
        "direction": "out"
    }
  ],
  "disabled": false
 }

此外,您可以使用 HttpTrigger 函数,但该函数需要处理验证消息。

于 2018-05-31T16:25:38.677 回答