首页 文章

Azure Stream Analytics事件中心输出 - 收到无效对象

提问于
浏览
0

使用ASA作业将输入作为IoT Hub和Event Hub作为输出,使用一个流式传输单元和每秒36条消息 .

ASA将多个对象作为单个字符串发送到事件中心 .

例如 . - 当我通过上传示例IoT Hub输入json文件来测试ASA作业时,获取单行中的跟随对象(输出中每行一个对象),这是预期的 - “{”assetbarcode“:”MobileGW153353803144884Asset“,”sensorruleid“:1159, “GROUPID”:681}”

但是当启动ASA作业并启动C#事件集线器接收器将多个对象作为单个字符串 - “{”assetbarcode“:”MobileGW153353803144884Asset“,”sensorruleid“:1159,”groupid“:681} {”assetbarcode“:”MobileGW153353803144884Asset“,” sensorruleid“:1159,”groupid“:681} {”assetbarcode“:”MobileGW153353803144884Asset“,”sensorruleid“:1159,”groupid“:681}”

所以它无法反序列化,因为它是无效的json . String不是数组或逗号分隔的对象 .

推荐C#接收器 - https://github.com/Azure/azure-event-hubs/blob/master/samples/DotNet/Microsoft.Azure.EventHubs/SampleEphReceiver/SimpleEventProcessor.cs

1 回答

  • 1

    如果将输出配置为线分隔,则此输出是预期的 . 要反序列化,您可以逐行读取每个行的反序列化器或者让JObject的反序列化器序列 .

    如果您更喜欢json数组,请选择数组 . This page有更多细节 . 请注意,如果作业在关闭文件之前重新启动,则文件可能会丢失关闭"]"

相关问题