I tried to insert the data into event hub for that followed this link to created the Free Trial event hub in azure portal and configured the connectionstring, eventHubName in my sample .Net application(referred link)
sample code:
class Program
{
const string eventHubName = "";
const string connectionString = @"";
public static async Task Main(string[] args)
{
await EventHubIngestionAsync();
}
public static async Task EventHubIngestionAsync()
{
await using (var producerClient = new EventHubProducerClient(connectionString, eventHubName))
{
int counter = 0;
for (int i = 0; i < 100; i++)
{
int recordsPerMessage = 3;
try
{
var records = Enumerable
.Range(0, recordsPerMessage)
.Select(recordNumber => $"{{\"timeStamp\": \"{DateTime.UtcNow.AddSeconds(100 * counter)}\", \"name\": \"{$"name {counter}"}\", \"metric\": {counter + recordNumber}, \"source\": \"EventHubMessage\"}}");
string recordString = string.Join(Environment.NewLine, records);
EventData eventData = new EventData(Encoding.UTF8.GetBytes(recordString));
Console.WriteLine($"sending message {counter}");
// Optional "dynamic routing" properties for the database, table, and mapping you created.
//eventData.Properties.Add("Table", "TestTable");
//eventData.Properties.Add("IngestionMappingReference", "TestMapping");
//eventData.Properties.Add("Format", "json");
using EventDataBatch eventBatch = await producerClient.CreateBatchAsync();
eventBatch.TryAdd(eventData);
IEnumerable dd = null;
await producerClient.SendAsync(dd);
}
catch (Exception exception)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("{0} > Exception: {1}", DateTime.Now, exception.Message);
Console.ResetColor();
}
counter += recordsPerMessage;
}
}
}
}
When running CreateBatchAsync getting the 'A connection attempt failed because the connected party did not properly respond'.

I tried both the connection string and Access control method getting the same error.

Naimish MakwanaPosted Feb 3, 2023, 6:38 AM
Hello Tamil,
Below could be the reasons for the error. Please check that once.
Please refer below link:
https://stackoverflow.com/a/68411252/3054222
Thanks
Naimish