Skip to content

Azure Event Hubs connector

Azure Event Hubs connector

The Azure Event Hubs connector sends rule results as events in one hub.

Use it for event streaming in Azure. The action names the hub.

flowchart LR
Rule["rule engine"] -- "hub" --> Action["event hubs action"]
Action -- "events" --> Sink["event hubs sink"]
Sink -- "send batch" --> Hub["Event Hub"]

Before you start

  • Create a namespace and hub.
  • Create a SAS policy with send access.
  • For a full build, enable --features azure_eventhubs. The default build answers 400 and names the feature.

Settings

Connector settingRequiredMeaning
namespaceyesService Bus namespace.
endpointnoOverride. Absent means the namespace host.
shared_access_key_nameyesSAS policy name.
shared_access_keyyesSAS key.
timeoutnoRequest timeout in milliseconds.
authenticationnoReference form. password holds the namespace connection string.
bootstrap_hostsnoReference form. Names the namespace host and port.
sslnoReference form. An empty object selects the TLS default.

The broker derives the namespace and SAS pair from authentication, bootstrap_hosts or the flat fields. The flat fields stay valid.

Action settingRequiredMeaning
event_hubyesTarget hub.
partition_keynoPartition key template.
user_propertiesnoCustom application properties with template values.

Example action:

{
"name": "hub-events",
"type": "azure_eventhubs",
"connector": "hub-local",
"parameters": {
"event_hub": "hub-a"
}
}

Limits

  • A missing namespace, key or hub answers 400 and names the field.
  • A failed batch counts one failed forward on the action.
  • Live qualification runs at release. This build proves delivery with a loopback fake.

Next steps

Check that it works

Create the connector. The broker answers 201 with the kind when the build holds the feature, else 400 names it. Both answers print ok.

[node]
id = "docs-connector-azure-event-hubs"
[listeners.tcp]
bind = "0.0.0.0:1883"
[listeners.api]
bind = "0.0.0.0:18083"
[logging]
level = "warn"
[auth]
allow_anonymous = true
Terminal window
python3 - <<'PY'
import json, os, urllib.request
port = os.environ.get("API_PORT", "18083")
key = os.environ["API_KEY"]
body = json.dumps({"name": "docs-azeh-1", "type": "azure_eventhubs",
"namespace": "ns-1", "endpoint": "http://127.0.0.1:5672",
"shared_access_key_name": "send",
"shared_access_key": "secret"}).encode()
req = urllib.request.Request(
f"http://127.0.0.1:{port}/api/v5/connectors", data=body, method="POST",
headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"})
try:
with urllib.request.urlopen(req, timeout=5) as res:
status, created = res.status, json.load(res)
except urllib.error.HTTPError as err:
status, created = err.code, json.load(err)
assert status in (201, 400), (status, created)
if status == 201:
assert created["type"] == "azure_event_hub_producer", created
else:
assert "azure" in created["message"], created
print("ok")
PY
ok