避免对通过 Python SDK 发送到事件中心的数据进行 base64 编码

Avoid base64 encoding on my data sent to Event Hub via Python SDK

我正在向 Azure 事件中心发送一个 json 对象(在 python 中),该对象通过事件中心的事件捕获功能路由到 Blob 存储。该文件存储在 Apache AVRO 中。当我在在线 AVRO reader 上上传文件时,我看到类似这样的内容 ..AVRO Reader Snip

实际数据在图像的正文中。我不希望 Azure 事件中心将我的数据编码为 base64。我应该对以下代码进行哪些更改。

    
    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 事件中心将消息正文中的数据作为不透明字节数组进行处理。它从不在 avro 写入之前对其进行编码。