Event Hub

Overview

The Event Hub builder creates event hub namespaces, event hubs, consumer groups and authorization rules in a single builder.

  • Event Hub Namespace (Microsoft.EventHub/namespaces)
  • Event Hub (Microsoft.EventHub/namespaces/eventhubs)
  • Consumer Group (Microsoft.EventHub/namespaces/eventhubs/consumergroups)
  • Authorization Rule (Microsoft.EventHub/namespaces/eventhubs/AuthorizationRules")

The Event Hub builder works in a similar fashion to the web app builder in that it automatically creates the host (in this case, the event hub namespace) when creating the event hub. If you wish to create multiple hubs in the same namespace, configure the namespace-level properties in the first event hub; subsequent event hubs should link to the namespace of the hub created by the first hub.

Builder Keywords

Applies ToKeywordPurpose
Namespacenamespace_nameSets the name of the event hub namespace, if you are creating the namespace along with the hub.
NamespaceskuSets the SKU of the event hub namespace.
NamespacecapacitySets the capacity of the event hub namespace (see here for more details)
Namespaceenable_zone_redundantEnables zone redundancy on the event hub namespace.
Namespaceenable_auto_inflateEnables auto inflate throughput; you must supply the maximum throughput level.
Namespacedisable_auto_inflateDisables auto inflate throughput.
Event HubnameSets the name of the event hub.
Event Hubmessage_retention_daysSets the number of days to retain messages on the event hub.
Event HubpartitionsSets the number of partitions on the event hub.
Event Hubadd_consumer_groupCreates a consumer group for the event hub. The default consumer group $Default gets created automatically.
Event Hubadd_authorization_ruleAdds a named authorization rule on the event hub.
Event Hublink_to_namespaceSets the name of an existing or already-defined event hub namespace that this event hub should link to.
Event Hubcapture_to_storageActivates Event Hub data capture to a Storage Account. Takes in a storage account or resource name, and the container to write events to.

Configuration Members

MemberPurpose
DefaultKeyGets an ARM expression for the root namespace key of the Event Hub namespace.
GetKeyGets an ARM expression for a named key on this event hub.

Example

open Farmer
open Farmer.Builders

let storage = storageAccount {
    name "isaacssuperstorage"
}

let primaryHub = eventHub {
    namespace_name "allmyevents"
    sku EventHub.Standard
    enable_zone_redundant
    enable_auto_inflate 3
    add_authorization_rule "FirstRule" [ EventHub.Listen; EventHub.Send ]
    add_authorization_rule "SecondRule" AllAuthorizationRights

    name "first-hub"
    partitions 2
    message_retention_days 3
    add_consumer_group "myGroup"
}

let secondHub = eventHub {
    name "second-hub"
    link_to_namespace "allmyevents"
    partitions 1
    message_retention_days 1
    capture_to_storage myStorageAccount "mycontainer"
}