Welcome to Part 2 of Azure functions: What are they good for? In Part 1, we did a quick review of what Azure Functions were and focused on the trigger aspect of Functions. By focusing on the triggers, we were able to highlight different scenarios that best suited an Azure Function’s usage. Let’s pick up where we left off in part 1, which covered the HTTP/WebHook trigger, Timer trigger, Azure Blob Storage trigger, and the Azure Queue Storage trigger. In this post, we will be exploring usages for the Azure Service Bus Queue/Topic trigger, Azure Event Hub trigger, IoT Hub (Event Hub) trigger, Azure Event Grid trigger, and last but not least, the Azure Cosmos DB trigger.
Azure Service Bus Queue/Topic Trigger
The Azure Storage Queue is not the only queue service with Azure Function triggers. The more robust Service Bus executes its trigger whenever a message is added to a specific Service Bus Queue or Service Bus Topic.
- Act as a consumer in a Durable Function fan-out solution as an alternative to Azure Storage Queue (view some code)
- Using an Azure Service Bus Topic Subscription (view some code)
Azure Event Hub Trigger
Event Hubs are triggered whenever a new event is received.
- Streaming at Scale with Azure Event Hubs, Functions and Cosmos DB (view some code)
- Read Temperature data from Event Hub messages (view some code)
- Matchmaking system using Azure Functions and Redis (view some code)
Azure IoT Hub (Event Hub) Trigger
The IoT Hub trigger is tied to Event Hubs in that this trigger will run whenever an IoT Hub delivers a new message for Event Hub-compatible endpoints.
- Azure IoT Edge Watchdog (view some code)
- Processing data from IoT Hub (view some code)
- Processing messages sent to an IoT Hub implemented with the Complementary Code Pattern (view some code)
- Realtime Flight Tracking (view some code)
Azure Event Grid Trigger
Rounding out our list of event-based triggers is the Event Grid trigger. This trigger is fired whenever an Event Grid receives a new event.
- Subscribing an Azure Function to Event Grid events via Terraform (view some code)
- Performing Azure Machine Learning via a No Code Deployment in Python (view some code)
Cosmos DB Trigger
The Cosmos DB trigger uses the Azure Cosmos DB Change Feed to listen for inserts and updates inside of a document collection. A very important detail to note is that the change feed publishes inserts and updates, but not deletions.
- Real-Time Data Analysis with Cosmos DB Change Feed (view some code)
- Azure Friday: Serverless geo-distributed applications with Azure Cosmos DB (view some code)
- Java Trigger Examples include a Cosmos DB Trigger (view some code)
In the list of use cases, something in particular needs to be called out. That call-out goes towards highlighting the incredible flexibility of Azure Functions, this time in regards to programming languages. Azure Functions are not restricted to the .Net language, as can be seen by the Python and Java examples listed. Azure Functions support a variety of languages including .Net (C# and F#), JavaScript/TypeScript, Java, Python, and even PowerShell. The flexibility of Azure Functions doesn’t just lend itself to use cases but also programming styles.
This post concludes a review of some use cases for Azure Functions. Part 1 & 2 should serve as inspiration for how Azure Functions can connect other Azure resources, be included as part of a process or workflow, and in general help round out a solution.