Search code examples
azureazure-eventhubazure-stream-analytics

Azure Stream Analytics to Event Hub batching not putting events in a list


I currently have a ASA Job that is streaming to an eventhub. From what I understand it may combine events from my query into batches for throughput reasons. However, when I check my output eventhub using service bus explorer, my events are not kept in a list like this:

[
  {
    "Payload": "test1"
  },
  {
    "Payload": "test2"
  }
]

and instead show up as

{"Payload": "test1"}
{"Payload": "test2"}

I am trying to create parity with an old system that seems to need the batched events to come in a list. Is there a way to specify this through options or my queries?


Solution

  • The setting you are looking for is Format in the EH output configration. You should switch it from line separated to array.

    Pasting the doc here:

    Format : Applicable only for JSON serialization. Line separated specifies that the output is formatted by having each JSON object separated by a new line. If you select Line separated, the JSON is read one object at a time. The whole content by itself would not be a valid JSON. Array specifies that the output is formatted as an array of JSON objects.

    This is line separated:

    {"Payload": "test1"}
    {"Payload": "test2"}
    

    This is array:

    [
      {
        "Payload": "test1"
      },
      {
        "Payload": "test2"
      }
    ]