I am trying to consume EventHub messages from a WebJob, without avail. The job builds and runs without throwing any exceptions, but the trigger is never called. I am referencing Microsoft.Azure.WebJobs, Microsoft.Azure.WebJobs.Extensions and Microsoft.Azure.WebJobs.ServiceBus v2.0.0.0-beta2.
Here's my code:
Program.cs:
public static void Main()
{
var eventHubConfig = new EventHubConfiguration();
string eventHubName = "myHub";
eventHubConfig.AddReceiver(eventHubName, "Endpoint=sb://xxxx.servicebus.windows.net/;SharedAccessKeyName=xxxx;SharedAccessKey=yyyy");
config.UseEventHub(eventHubConfig);
JobHost host = new JobHost(config);
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
host.RunAndBlock();
}
Functions.cs:
public static void Trigger([EventHubTrigger("myHub")] string message)
{
_logger.Debug("Message received");
}
In my app.config, I've set the appropriate connection strings for AzureWebJobsDashboard, AzureWebJobsServiceBus and AzureWebJobsStorage.
I've tried everything from using batches of messages to changing the method signature of the trigger method, specifically the parameter type to EventData or byte[]. Nothing works. I should note messages are sent to the EventHub as byte arrays wrapped in an EventData.
What am I missing?
Thank you for your time and looking forward to replies.
According to your description, I followed Azure WebJobs SDK EventHub support and Get started with Event Hubs to test this issue on my side. And I could receive messages, you could refer to my code snippet:
Program.cs
Functions.cs
Packages.config
Result:
Also, you could log into Azure Portal, check the overview blade of your Event Hub as follows: