During Build 2016 Day 2, Microsoft today announced Azure Functions Preview, a serverless compute platform for building IoT solutions. Azure Functions can trigger on events in Azure or even external services. Since it is hosted on cloud, you only pay per execution. Microsoft also announced that it is an open source runtime which can run anywhere.
This is a direct competitor to AWS Lambda which also lets you run code without provisioning or managing servers and you pay only for the compute time you consume.