3
votes

I am learning Azure Events Hub. A simple application i have downloaded from this link https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-dotnet-standard-getstarted-send . But when i try to send message, its giving me this error:

10/23/2018 11:11:13 PM > Exception: Put token failed. status-code: 404, status-description: The messaging entity 'sb://demo.servicebus.windows.net/myTeam' could not be found. TrackingId:[My Tracking ID], SystemTracker:iot-bd-madness.servicebus.windows.net:IoT-BD-Madness, Timestamp:10/23/2018 5:11:18 PM.

In Azure Event Hub Dashboard all incoming requests (sending from console app) are visible with chart. but those are all request actually failed when i tried in console application

N.B:the given connectionstring is not real

public class Program
{
    private static EventHubClient eventHubClient;
    private const string EventHubConnectionString = "Endpoint=sb://iot-bd-madness.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
    private const string EventHubName = "Iot-Bd-Madness";

    public static void Main(string[] args)
    {
        MainAsync(args).GetAwaiter().GetResult();
    }

    private static async Task MainAsync(string[] args)
    {
        // Creates an EventHubsConnectionStringBuilder object from a the connection string, and sets the EntityPath.
        // Typically the connection string should have the Entity Path in it, but for the sake of this simple scenario
        // we are using the connection string from the namespace.
        var connectionStringBuilder = new EventHubsConnectionStringBuilder(EventHubConnectionString)
        {
            EntityPath = EventHubName
        };

        eventHubClient = EventHubClient.CreateFromConnectionString(connectionStringBuilder.ToString());

        await SendMessagesToEventHub(100);

        await eventHubClient.CloseAsync();

        Console.WriteLine("Press any key to exit.");
        Console.ReadLine();
    }

    // Creates an Event Hub client and sends 100 messages to the event hub.
    private static async Task SendMessagesToEventHub(int numMessagesToSend)
    {
        for (var i = 0; i < numMessagesToSend; i++)
        {
            try
            {
                var message = $"Message {i}";
                Console.WriteLine($"Sending message: {message}");
                await eventHubClient.SendAsync(new EventData(Encoding.UTF8.GetBytes(message)));
            }
            catch (Exception exception)
            {
                Console.WriteLine($"{DateTime.Now} > Exception: {exception.Message}");
            }

            await Task.Delay(10);
        }

        Console.WriteLine($"{numMessagesToSend} messages sent.");
    }
}

}

1
In Azure Event Hub Dashboard all incoming requests (sending from console app) are visible with chart. but those are all request actually failed when i tried in console application. could you please check my codes.sebu
@DavidMakogon i have edited my question again with proper connectionstring except security key.sebu
i ran into exactly the same issue, make sure you have both the event hub namespace AND event hub are created!Vivian_S.O.

1 Answers

11
votes

I ran into same problem. My EventHubName = "myeventhubname" was wrong. I passed the Event Hubs Namespace value - rounded in red. It gave error. I changed it to value under Event Hub page left column -> click Entities -> Event Hubs I used the name that was shown in the table rounded in green. enter image description here