Fabric API - Events
The Kafka and REST connections for an eventstream endpoint, every field of each.
An eventstream's custom endpoint accepts Kafka and REST clients, so the connections below are Zato's Kafka and REST connections configured for Fabric. The events page uses them in services. Eventhouses are queried with the Fabric connection's query_events.
Where the values come from
All values on this page come from the Details pane of the eventstream's custom endpoint, on the SAS Key Authentication page of its Kafka tab, whether the endpoint is a source (Zato sends) or a destination (Zato receives):
| In Fabric | Used as |
|---|---|
| Bootstrap server | The Kafka address, <namespace>.servicebus.windows.net:9093 |
| Topic name | The Kafka topic, and the <topic name> in the REST address |
| Connection string-primary key | The password of a Basic Auth definition for the PLAIN mechanism |
| Consumer group | The Kafka channel's consumer group, on the Basic page of the destination |
The namespace is the first part of the bootstrap server, up to .servicebus.windows.net.
Security definitions
Two kinds of definition sign a Kafka connection in, and both are created under Security in the Dashboard:
| Mechanism | Definition | Fields |
|---|---|---|
OAUTHBEARER | Bearer token | Username the application (client) ID, Password the client secret, Auth endpoint https://login.microsoftonline.com/<tenant ID>/oauth2/v2.0/token, Scopes https://<namespace>.servicebus.windows.net/.default |
PLAIN | Basic Auth | Username $$ConnectionString, Password the connection string |
The username is entered as $$ConnectionString because a value starting with a single $ names an environment variable, and doubling it gives the literal $ConnectionString.
An environment holds one Bearer token definition per client ID, so the Kafka scope and the REST scope each sign in as an app registration of their own, added to the workspace as a Contributor.
Kafka outgoing connection
Under Connections → Message queues → Kafka → Outgoing connections:
| Field | Value |
|---|---|
| Name | Any, used as self.out.kafka[name] |
| Address | The bootstrap server |
| Topic | The topic name |
| SSL | On |
| Security | The Bearer token or Basic Auth definition |
| SASL mechanism | OAUTHBEARER or PLAIN, matching the definition |
outgoing_kafka:
- name: Fabric Events
address: <namespace>.servicebus.windows.net:9093
topic: <topic name>
security: Fabric Events Token
sasl_mechanism: OAUTHBEARER
ssl: true
A dict passed to send is JSON-encoded before it leaves:
event = {
'event_type': 'admission',
'location': 'Riverside',
'admission_id': 'ADM-1041',
}
self.out.kafka['Fabric Events'].send(event)
Kafka channel
Under Connections → Message queues → Kafka → Channels:
| Field | Value |
|---|---|
| Name | Any |
| Address | The bootstrap server |
| Topic | The topic name |
| Consumer group | The group created for Zato on the destination |
| Service | The service to run for each event |
| SSL | On |
| Security | The Bearer token or Basic Auth definition |
| SASL mechanism | OAUTHBEARER or PLAIN, matching the definition |
channel_kafka:
- name: Fabric Alerts
address: <namespace>.servicebus.windows.net:9093
topic: <topic name>
group_id: zato
service: fabric.notify-purchasing
security: Fabric Events Token
sasl_mechanism: OAUTHBEARER
ssl: true
The eventstream sends events in batches, as a JSON list, which the service receives parsed in self.request.input:
REST alternative for sending
The same endpoint also takes events over HTTPS. Under Connections → REST → Outgoing connections:
| Field | Value |
|---|---|
| Host | https://<namespace>.servicebus.windows.net |
| URL path | /<topic name>/messages |
| Data format | JSON |
| Security | A Bearer token definition with Scopes https://eventhubs.azure.net/.default |
The body is a list of events, each wrapped in Body, sent with the endpoint's own content type:
body = json.dumps(event)
payload = [{'Body': body}]
headers = {'Content-Type': 'application/vnd.microsoft.servicebus.json'}
self.rest['Fabric Events REST'].post(payload, headers=headers)
See also
| Page | What it covers |
|---|---|
| Fabric events | Services that send, receive and read events with these connections |
| Fabric API - Queries | query_events, KQL queries against an eventhouse through the Fabric connection |
| Fabric API - Connection | The app registration the Kafka definition signs in as |