Event hub - Schema registry - Avro Consumer not deserializing using .Net Core

DS 21 Reputation points


I am trying to de-serialize event hub event which is Avro based.
I have written code based on the article (https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/schemaregistry/Microsoft.Azure.Data.SchemaRegistry.ApacheAvro) but event is not getting de-serialized.
Also, there is no error or exception. Any pointer on this is really helpful.

// Create a producer client that you can use to send events to an event hub
EventHubConsumerClient consumerClient = new EventHubConsumerClient(EventHubConsumerClient.DefaultConsumerGroupName, connectionString, eventHubName);

            // Create a schema registry client that you can use to serialize and validate data.    
            var schemaRegistryClient = new SchemaRegistryClient(schemaRegistryEndpoint, credential: new DefaultAzureCredential());  

            var serializer = new SchemaRegistryAvroSerializer(schemaRegistryClient, schemaGroup, new SchemaRegistryAvroSerializerOptions { AutoRegisterSchemas = true });  

            await foreach (PartitionEvent receivedEvent in consumerClient.ReadEventsAsync())  
                MessageContent msgContent = new MessageContent();  
                msgContent.Data = receivedEvent.Data.EventBody;  
                msgContent.ContentType = "avro/binary+schemaId";  
                var deserialized = (Shipment) await serializer.DeserializeAsync(msgContent, typeof(Shipment));  
        catch (Exception ex)  
Azure Event Hubs
Azure Event Hubs
An Azure real-time data ingestion service.
459 questions
{count} votes