Azure功能输出到EventHub

发布于 2025-02-12 08:42:11 字数 2296 浏览 0 评论 0 原文

我有一个使用nodejs构建的Azure函数,该功能在HTTP触发器上接收数据,处理数据,然后必须将处理的数据输出到Azure事件中心,以在Azure ADX中摄入。输出数据是JSON格式的有效载荷。

流量:
AZ功能(HTTP触发) - > AZ Event Hub - > AZ ADX

使用EventHubProDucerClient类(来自NPM @azure/event-hubs),我能够将数据发布到Event Hub,然后将其链接到ADX并摄入数据。 (如果您构建应用程序服务,则通常是遵循的方法)。

我想利用烤制 azure函数 bindings (使用 microsoft.azure.functions.functions.extensionbundle )和i已经设置了设置:

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": ["post"],
      "route": "upload"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    },    
    {
      "type": "eventHub",
      "name": "outputEventHub",
      "eventHubName": "%AZEH_EVENTHUB_NAME%",
      "connection": "AZEH_CONNECTION_STRING",
      "direction": "out"
    }
}

ref: https://github.com/uglide/azure-content/blob/master/articles/azure-functions/functions-bindings-event-hubs.md#azure-event-event-event-nub-hub-ub-ub-ub-unputputput-tupting

我一直在尝试在绑定的数据类型属性上找到文档(在function.json中设置),但我能找到的最好的是文档指定受支持的类型,但没有说明如何实施它。我看到的最好的是设置

“ dataType”:“ string”

支持类型的列表:

  • azure.messaging.eventhubs.eventdata
  • string byte
  • byte byte byte plin plun
  • tale pline grain nod clr对象(poco)

ref: https://github.com/microsoftdocs/azure-docs/blob/main/articles/azure-functions/functions-bindings-bindings-event-event-hubs-enput.md

处理触发器,我将上下文绑定到JSON数据之类的上下文:

context.bindings.outputEventHub = jsonData;

但是数据未能浏览到ADX。

任何人都有一些有关如何通过事件中心设置AZ函数以将数据摄入ADX的引用?

I have a Azure Function built with NodeJS which receives data on a HTTP trigger, processes the data and then has to output the processed data to an Azure Event Hub to be ingested in Azure ADX. The output data is a JSON formatted payload.

Flow:
AZ Function (HTTP Trigger) -> AZ Event Hub -> AZ ADX

Using the EventHubProducerClient class (from NPM @azure/event-hubs), I am able to post the data to the event hub, which it then linked to ADX and the data is ingested. (This is typically the method followed if you build a app service).

I want to make use of the baked-in Azure Functions Bindings for eventHub (using the Microsoft.Azure.Functions.ExtensionBundle), and I have set the settings:

{
  "bindings": [
    {
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req",
      "methods": ["post"],
      "route": "upload"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    },    
    {
      "type": "eventHub",
      "name": "outputEventHub",
      "eventHubName": "%AZEH_EVENTHUB_NAME%",
      "connection": "AZEH_CONNECTION_STRING",
      "direction": "out"
    }
}

Ref: https://github.com/uglide/azure-content/blob/master/articles/azure-functions/functions-bindings-event-hubs.md#azure-event-hub-output-binding

I have been trying to find the documentation on the dataType property in for the bindings (set up in function.json), but the best I could find was a document specifying the supported types, but not stating how to implement it. The best I saw was setting

"dataType": "string"

List of supported types:

  • Azure.Messaging.EventHubs.EventData
  • String
  • Byte array
  • Plain-old CLR object (POCO)

Ref: https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-functions/functions-bindings-event-hubs-output.md

In my function that handles the trigger, I set the context binding to the JSON data like:

context.bindings.outputEventHub = jsonData;

but the data fails to pull through to ADX.

Anyone have some reference on how to set up a AZ function to ingest data in to ADX via Event Hub?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

左耳近心 2025-02-19 08:42:13

我相信数据是从Azure函数正确发送到事件中心的。但是,当摄入量发生在Azure Data Explorer上时,您将面临问题。您可以确认数据格式是否在配置了从事件中心摄入数据到Azure数据探索的数据时指定的。请参阅配置部分。如果您的事件中心具有不同的数据格式,则您从Azure功能发送的数据格式,则可以观察到该问题。请确保您正在序列化数据。如果您要传递JSON对象,则可以利用JSONCONVERT.SerializeObject(YourDaata)将JSON消息传递给事件中心。

I believe the data is send correctly from azure function to event hub. But when the ingestion happen at azure data explorer then you are facing the issue. Can you please confirm data format have you specified when you have configured the ingesting the data from event hub to azure data explore. Please refer to the target table configuration section. In case if your event hub have the different data format that what you are sending from your azure function then you could observe the issue. Please make sure you are serializing the data. In case if you are passing JSON object then you can leverage the JsonConvert.SerializeObject(yourdaata) to pass the JSON message to the event hub.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文