I'm starting to develop an Azure Function that sends messages to an Event Hub.
Using the example provided on Azure Event Hubs output binding for Azure Functions I'm able to send an event using the return value of the HTTP trigger.
[FunctionName("EventHubOutput")]
[return: EventHub("outputEventHubMessage", Connection = "EventHubConnectionAppSetting")]
public static string Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
return $"{DateTime.Now}";
}
For my implementation, I don't want to use the return value of the function trigger (in my case HTTP) and would like to use the output of a method within the function. The reason for this is that I would like to validate the request method and only send the message to the event hub is it passes validation.
I can replace return: with method: but I can't find any documentation which tells me how to implement method:.
If you don't want to use output binding, you can use code to send directly, they are the same principle. Code about how to send a message to the event hub: