Use Azure Functions to Consume Telemetry Data
    • Dark
      Light
    • PDF

    Use Azure Functions to Consume Telemetry Data

    • Dark
      Light
    • PDF

    Article Summary

    #ServerlessTips - Azure Functions
    Author: Steef-Jan Wiggers Azure MVP

    Functions are designed for real-time, large-scale event processing, easy to configure, and have out-of-the-box integrations with Event Hubs, Cosmos DB, Service Bus, and other Azure managed services (through bindings). You can build a function fairly quickly to ingest data from Event Hubs or Service Bus queue or topic and persist in a Cosmos DB Collection.

    With the Event Hub or Service Bus binding, you can set the input of the data stream you like to ingest and with the Cosmos DB binding you can specify the collection you want to persist the data. Furthermore, within the function, you can potentially add logic to operate on the data – for instance, data time, string manipulation or calculations.

    using System;
    using System.Threading.Tasks;
    
    public static void Run(string mySbMsg, ILogger log, out object outputDocument)
    {
        log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
    
        outputDocument = new
            {
                mySbMsg
            };
        
    }
    

    The code above shows ingestion of a message (mySbMsg) and output (write) to an output document (tied to a Cosmos DB binding).

    Tip 17 - Use Azure Function to consume telemetry data Pic 1.png

    You configure the bindings through the integrate tab in the Azure Portal or in the function.json file.
    Ingesting data using Azure Functions can be right git for your cloud solution architecture. However, do consider if consumption plan is sufficient or whether you need an App Service Plan.

    Other references:
    See also the Microsoft Blog post - Considering Azure Functions for a serverless data streaming scenario
    Turbo360 (Formerly Serverless360) blog post - Use Azure Functions to process high throughput messages: Yes or No?

    Azure-functions.png


    Was this article helpful?