Azure / azure-functions-java-library

Contains annotations for writing Azure Functions in Java
MIT License
42 stars 42 forks source link

Reading events metadata in Event triggered function #115

Closed muneeba-mughal closed 4 years ago

muneeba-mughal commented 4 years ago

Hi there! I'm trying to write an Azure function triggered by EventHub. My function looks like this:

@FunctionName("eventHubMonitor")
    fun run(
        @EventHubTrigger(
            name = "event",
            eventHubName = "eventhub",
            connection = "AzureEventHubConnection"
        ) message: String,
        context: ExecutionContext
    ) {
         context.logger.info("Event trigger processed a ${message} request.")
        }

In the message I only get the body of the event. I have important information in SystemProperties of the event that I need to read as well. How can I read those?

Thank you so much in advance <3

muneeba-mughal commented 4 years ago

I figured it out. It's described beautifully in this repository: https://github.com/Azure/azure-functions-java-worker

I will create a proposal for updating the documentation. :)