Event Grid


The Event Grid is a simple but powerful builder that links events from Azure services such as Storage and App Service to one or many subscribers which can consume the events. The event grid builder supports a degree of type safety - all system events are provided from a strongly-typed list, and events are directly linked to specific builders - so, for example, you cannot accidentally subscribe to Storage Account events if the event publisher is a Web App. It supports the following ARM resources.

  • Topics (Microsoft.EventGrid/systemTopics)
  • Subscriptions (Microsoft.EventGrid/systemTopics/eventSubscriptions)

Builder Keywords

topic_nameThe name of the topic that will be created.
sourceOptional, defaults to the current resource group. The source of the events. See below for the full list of builder configurations that are supported.
add_queue_subscriberAdds a new storage queue subscriber. Requires the storage account config that will receive the events, the queue name and the list of events to subscribe to.
add_webhook_subscriberAdds a new web hook (HTTP) subscriber. Requires the web app config that will receive the event, associated URI local path and the list of events to subscribe to. Also contains an overload that takes in a Web App name and the full Uri of the web hook.
add_eventhub_subscriberAdds a new event hub subscriber. Requiresthe event hub builder config that will receive the events and the list of events to subscribe to.
add_function_subscriberAdds a new Azure Functions subscriber. Requires the function app, the handler name and the list of events to subscribe to.

Supported Sources

Farmer supports the following Event Grid sources using Farmer builders:

BuilderEvents namespace

Suported Destinations

  • EventHub (add_eventhub_subscriber),
  • StorageQueue (add_queue_subscriber),
  • WebHook (add_webhook_subscriber),
  • ServiceBus Queue (add_servicebus_queue_subscriber),
  • ServiceBus Topic (add_servicebus_topic_subscriber).


The following sample creates a source storage account that emits events on the event grid topic, whilst two destinations are created: an event hub and a storage queue, each listening for different events.

open Farmer
open Farmer.Builders

let queueName = "events"

let storageSource = storageAccount { name "isaacstorageacc"; add_private_container "data" }
let destionationHub = eventHub { name "isaachub"; namespace_name "isaacns" }
let destinationStorage = storageAccount { name "destinationstorage"; add_queue queueName; add_private_container "events" }

let eventHubGrid = eventGrid {
    topic_name "isaacHubTopic"
    source storageSource
    add_eventhub_subscriber destionationHub [ SystemEvents.Storage.BlobCreated; SystemEvents.Storage.BlobDeleted ]
    add_queue_subscriber destinationStorage queueName [ SystemEvents.Storage.BlobCreated ]

let template =
    arm {
        add_resources [