事件中心的事件网格订阅以在特定分区中提取日志
Event Grid Subscription for Event Hub to ingest logs in particular partition
创建事件网格订阅并使用 eventhub 作为端点时,无法指定所有消息应发送到的分区 ID。可以通过 Webhook 实现吗?
我发现可以通过 Rest API 看到这里。它使用以下 url。 https://{serviceNamespace}.servicebus.windows.net/{eventHubPath}/publishers/{deviceId}/messages。
我正在尝试将这些事件提取到事件中心。但我想要的是将这些事件摄取到事件中心的特定分区中。
是否可以通过事件订阅(可能通过将 deviceid 作为参数传递)?或者是否有任何其他方法来配置事件订阅以将这些事件路由到事件中心中的特定 partitionID。
我正在使用 nodejs 编写无服务器代码,我正在通过 azure 门户创建事件网格订阅。
P.S。我从 Azure 支持团队确认目前不支持此功能,必须使用 Azure 功能将事件定向到特定的分区 ID。
最低限度的集成是使用 EventGridTrigger 函数与 EventHub 的输出绑定,请参阅以下实现:
#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 函数,但该函数需要处理验证消息。
创建事件网格订阅并使用 eventhub 作为端点时,无法指定所有消息应发送到的分区 ID。可以通过 Webhook 实现吗? 我发现可以通过 Rest API 看到这里。它使用以下 url。 https://{serviceNamespace}.servicebus.windows.net/{eventHubPath}/publishers/{deviceId}/messages。 我正在尝试将这些事件提取到事件中心。但我想要的是将这些事件摄取到事件中心的特定分区中。 是否可以通过事件订阅(可能通过将 deviceid 作为参数传递)?或者是否有任何其他方法来配置事件订阅以将这些事件路由到事件中心中的特定 partitionID。
我正在使用 nodejs 编写无服务器代码,我正在通过 azure 门户创建事件网格订阅。
P.S。我从 Azure 支持团队确认目前不支持此功能,必须使用 Azure 功能将事件定向到特定的分区 ID。
最低限度的集成是使用 EventGridTrigger 函数与 EventHub 的输出绑定,请参阅以下实现:
#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 函数,但该函数需要处理验证消息。