Send and receive messages from Azure Event Hubs using .Net Part 3 – Write the .Net console app for sending messages to the Azure Event Hub
1 min read

Send and receive messages from Azure Event Hubs using .Net Part 3 – Write the .Net console app for sending messages to the Azure Event Hub

Following the Microsoft Docs quickstart let’s write some code from their instructions!

Add the using statements in the programs.cs file

 using System;
 using System.Text;
 using System.Threading.Tasks;
 using Azure.Messaging.EventHubs;
 using Azure.Messaging.EventHubs.Producer;

Next go and get the namespace connection string and copy this so we can add the connection string to our code.

And inside the class add the constants and get the connection string and eventhub name from your event hub and copy them

private const string connectionString = "";
private const string eventHubName = "";

Finally replace the Main method with the method described in the link and build the project!

Now run the project and watch your three events being sent to your very own Azure Event Hub!

And inside your event hub you can now see the metrics updated.

Now in the next post we’ll create a storage and an app to receive the messages.

Leave a Reply