Azure Functions and Azure Event Grid
    • Dark
    • PDF

    Azure Functions and Azure Event Grid

    • Dark
    • PDF

    Article summary

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

    Event Grid is a service in Azure allowing the central management of Events – adhering to a proprietary schema or CNCF supported open-source cloud events. The concept of this service is straight forward; it lets you push events to a so-called Topic. The Topic has one or more subscribers of the event and thus will push events to those subscribers. One of those subscribers can be Azure Functions – accordingly act as an event handler.

    Tip 18 - Azure EventGrid and Functions Pic 1.png

    With a function as an event handler, you can process events you are interested in using code. Azure Functions provides a template for you with an Event Grid support through a binding.

    #r "Microsoft.Azure.EventGrid"
    using Microsoft.Azure.EventGrid.Models;
    public static void Run(EventGridEvent eventGridEvent,ICollector<string> outputSbMsg, ILogger log)
        //output to service bus queue

    Once you pick the Event Grid template and build your logic around it – can be as simple as routing the event to a Service Bus queue. Finally, you can add your function as an Event Grid subscription.

    Tip 18 - Azure EventGrid and Functions Pic 2.png

    When configuring the event grid subscription you need to provide a name, choose the schema (Event Grid is proprietary, Cloud Events open source, or your own input schema), pick a Topic (can be built in Topics in services such as storage), and select the resource. Next, you define a filter(s) for your subscription – subject based filters and/or any advanced filters. Lastly, you can enable dead-lettering, retries, and a subscription expiry date if necessary.

    With Azure Functions and Event Grid you can build a complete event-driven cloud-native solution in Azure.


    Was this article helpful?