Avoid base64 encoding on my data sent to Event Hub via Python SDK
Question:
I am sending a json object(in python) to Azure Event Hub which is routed to Blob Storage via Event Capture feature of Event Hub. This file gets stored in Apache AVRO. When I upload the file on online AVRO reader I see something like this ..AVRO Reader Snip
The actual data is in body of the image. I don’t want Azure Event Hub to encode my data to base64. What changes should I make to my below code.
producer = EventHubProducerClient.from_connection_string(conn_str=EVENTHUB_CONNECTION_STR, eventhub_name=eventhub)
async with producer:
dictionary_obj = {}
dictionary_obj['id'] = 1
dictionary_obj['Name'] = 'Alex'
dictionary_obj['Attr1'] = 1
MESSAGE = json.dumps(dictionary_obj)
event_data_batch = await producer.create_batch()
event_data_batch.add(EventData(MESSAGE))
await producer.send_batch(event_data_batch)
await producer.close()
Answers:
Azure Event Hubs handles the data in the message body as an opaque byte array. It never encodes it prior to avro write.
I am sending a json object(in python) to Azure Event Hub which is routed to Blob Storage via Event Capture feature of Event Hub. This file gets stored in Apache AVRO. When I upload the file on online AVRO reader I see something like this ..AVRO Reader Snip
The actual data is in body of the image. I don’t want Azure Event Hub to encode my data to base64. What changes should I make to my below code.
producer = EventHubProducerClient.from_connection_string(conn_str=EVENTHUB_CONNECTION_STR, eventhub_name=eventhub)
async with producer:
dictionary_obj = {}
dictionary_obj['id'] = 1
dictionary_obj['Name'] = 'Alex'
dictionary_obj['Attr1'] = 1
MESSAGE = json.dumps(dictionary_obj)
event_data_batch = await producer.create_batch()
event_data_batch.add(EventData(MESSAGE))
await producer.send_batch(event_data_batch)
await producer.close()
Azure Event Hubs handles the data in the message body as an opaque byte array. It never encodes it prior to avro write.