Trigger Azure Function with an IoT/Event Hub message

How to configure a serverless.yml for an Azure Function, so that it gets triggered when a device sends a message to Azure IoT Hub?
Basically I want my Azure function to work as subscriber in MQTT pub-sub Architecture and on receiving the message from IoT Hub my Azure function should insert the message in CosmosDB.

Any luck with that ?