If you are building an IoT solution in the cloud, chances are your focus is on the devices and what you can accomplish with them. You might want to process data coming from a network of devices in real time, analyze the data to gain insights, get alerted for special conditions, manage the devices themselves, and so on. What is less interesting to you is setting up and managing the infrastructure in the cloud, which will enable you to do the above. This is where serverless comes in.
Serverless technologies, like Azure Functions, take away the burden of managing infrastructure and enables you to focus on your IoT-powered business logic. IoT projects usually have variable traffic, which means accumulating infrastructure to account for peak loads, isn’t the best strategy. Adopting serverless allows your solutions to scale dynamically while keeping costs low.
This video shows a great application of a serverless architecture to receive data from a device, transform it in real time using machine learning, and send it back to the device. It is based on the DevKit Translator IoT project.
Process incoming device data in real time
Most IoT devices generate data that needs to be ingested and processed.
- This data could be regular telemetry data that needs to go through some custom processing before being visualized or archived for later analysis. In this case, triggering a serverless function from the built-in Azure Event Hubs endpoint in IoT Hub, is a perfect solution for the custom processing part.
- It could be a special condition alert, which needs to be acted upon with slightly different (and urgent) custom processing. In this case, triggering a serverless function using the message routing functionality of IoT Hub, for instance with Azure Service Bus queues, is a perfect solution.
Sending messages from cloud to device
Sending messages from your cloud applications to IoT devices is also a common scenario. IoT Hubs facilitate this through API which can be readily consumed from any application. Since sending such data is usually done as a part of a workflow, serverless functions again provide a quick, easy, and scalable mechanism to run the code meant to perform this specific part (firing messages off to devices), without worrying about where this code is running.
Manage and auto-scale your IoT solution
While a serverless backend removes any scale worries for the data processing part of your solution, you still want to ensure that you are appropriately scaling the capacity of IoT Hub itself to manage how much traffic can actually flow through to your serverless backend. This is where the Durable Functions feature of Azure Functions can provide a serverless method of monitoring and scaling the IoT Hubs so that your entire IoT project can effectively be auto-scale.
Additionally, using Azure Event Grid and Azure IoT Hub, you can also respond to device updates, like additions and deletions, in a serverless manner using Functions or Logic Apps.
Custom processing on IoT Edge
Businesses are increasingly demanding low-latency output from their IoT solutions. Solutions like Azure IoT Edge are allowing customers to transfer the capability of cloud technologies to their own devices. There are multiple scenarios in which some custom processing needs to be performed on the device itself without communicating with the cloud. Azure Functions on IoT Edge provides a powerful mechanism through which you can utilize the productive programming model of Azure Functions on your own devices. This allows consistency of architecture across your cloud and Edge applications.
These are just some of the examples of how Azure provides ways of building IoT applications using serverless technologies. The ease of use and low-cost nature of Azure Functions makes it a viable option for experimenting with many other IoT scenarios. We are looking forward to what you will build.