You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Send receive messages between Azure IoT MQ and Event Hubs or Kafka
3
-
description: Learn how to send and receive messages between Azure IoT MQ and Azure Event Hubs or Kafka.
2
+
title: Send and receive messages between Azure IoT MQ and Event Hubs or Kafka
3
+
description: Learn how to send and receive messages between Azure IoT MQ and Azure Event Hubs or Kafka using the Kafka connector.
4
4
author: PatAltimore
5
5
ms.author: patricka
6
6
ms.subservice: mq
7
7
ms.topic: how-to
8
8
ms.custom:
9
9
- ignite-2023
10
-
ms.date: 04/22/2024
10
+
ms.date: 06/06/2024
11
11
12
12
#CustomerIntent: As an operator, I want to understand how to configure Azure IoT MQ to send and receive messages between Azure IoT MQ and Kafka.
13
13
---
@@ -115,7 +115,7 @@ az deployment group create \
115
115
116
116
The *KafkaConnector* custom resource (CR) allows you to configure a Kafka connector that can communicate a Kafka host and Event Hubs. The Kafka connector can transfer data between MQTT topics and Kafka topics, using the Event Hubs as a Kafka-compatible endpoint.
117
117
118
-
The following example shows a *KafkaConnector* CR that connects to an Event Hubs endpoint using IoT MQ's Azure identity, it assumes other MQ resources were installed using the quickstart:
118
+
The following example shows a *KafkaConnector* CR that connects to an Event Hubs endpoint using different authentication types. It assumes other MQ resources were installed using the quickstart:
119
119
120
120
```yaml
121
121
apiVersion: mq.iotoperations.azure.com/v1beta1
@@ -151,7 +151,10 @@ spec:
151
151
kubernetes: {}
152
152
```
153
153
154
-
The following table describes the fields in the KafkaConnector CR:
154
+
---
155
+
156
+
157
+
The following table describes the fields in the KafkaConnector custom resource:
155
158
156
159
| Field | Description | Required |
157
160
| ----- | ----------- | -------- |
@@ -194,7 +197,7 @@ The authentication field supports different types of authentication methods, suc
194
197
| Field | Description | Required |
195
198
| ----- | ----------- | -------- |
196
199
| enabled | A boolean value that indicates whether authentication is enabled or not. | Yes |
197
-
| authType | A field containing the authentication type used. See [Authentication Type](#authentication-type)
200
+
| authType | A field containing the authentication type used. See [Authentication Type](#authentication-type) | Yes |
198
201
199
202
##### Authentication Type
200
203
@@ -206,9 +209,51 @@ The authentication field supports different types of authentication methods, suc
206
209
207
210
To learn how to use Azure Key Vault and the `keyVault` to manage secrets for Azure IoT MQ instead of Kubernetes secrets, see [Manage secrets using Azure Key Vault or Kubernetes secrets](../manage-mqtt-connectivity/howto-manage-secrets.md).
208
211
209
-
##### Authenticate to Event Hubs
212
+
### Authenticate to Event Hubs
213
+
214
+
#### [Managed identity](#tab/managed-identity)
210
215
211
-
To connect to Event Hubs using a connection string and Kubernetes secret, use `plain` SASL type and `$ConnectionString` as the username and the full connection string as the password. First create the Kubernetes secret:
216
+
To use managed identity, specify it as the only method under authentication. You also need to assign a role to the managed identity that grants permission to send and receive messages from Event Hubs, such as Azure Event Hubs Data Owner or Azure Event Hubs Data Sender/Receiver. To learn more, see [Authenticate an application with Microsoft Entra ID to access Event Hubs resources](/azure/event-hubs/authenticate-application#built-in-roles-for-azure-event-hubs).
217
+
218
+
```yaml
219
+
apiVersion: mq.iotoperations.azure.com/v1beta1
220
+
kind: KafkaConnector
221
+
metadata:
222
+
name: my-eh-connector
223
+
namespace: azure-iot-operations # same as one used for other MQ resources
To connect to Event Hubs using a connection string and Kubernetes secret, use `plain` SASL type and `$ConnectionString` as the username and the full connection string as the password.
To use Azure Key Vault instead of Kubernetes secrets, create an Azure Key Vault secret with the connection string `Endpoint=sb://..`, reference it with `vaultSecret`, and specify the username as `"$ConnectionString"` in the configuration.
301
+
To use Azure Key Vault instead of Kubernetes secrets, create an Azure Key Vault secret with the connection string `Endpoint=sb://..`, reference it with `vaultSecret`, and specify the username as `"$ConnectionString"` in the configuration.
302
+
303
+
Use the previous YAML example and change the authentication section to the following:
232
304
233
305
```yaml
234
306
authentication:
@@ -249,17 +321,7 @@ authentication:
249
321
# version: 939ecc2...
250
322
```
251
323
252
-
To use managed identity, specify it as the only method under authentication. You also need to assign a role to the managed identity that grants permission to send and receive messages from Event Hubs, such as Azure Event Hubs Data Owner or Azure Event Hubs Data Sender/Receiver. To learn more, see [Authenticate an application with Microsoft Entra ID to access Event Hubs resources](/azure/event-hubs/authenticate-application#built-in-roles-for-azure-event-hubs).
To use Azure Key Vault instead, make sure the [certificate and private key are properly imported](../../key-vault/certificates/tutorial-import-certificate.md) and then specify the reference with `vaultCert`.
369
+
To use Azure Key Vault instead, make sure the [certificate and private key are properly imported](../../key-vault/certificates/tutorial-import-certificate.md) and then specify the reference with `vaultCert`.
370
+
371
+
Use the previous YAML example and change the authentication section to the following:
283
372
284
373
```yaml
285
374
authentication:
@@ -310,6 +399,8 @@ keyVault:
310
399
# version: 939ecc2...
311
400
```
312
401
402
+
---
403
+
313
404
### Manage local broker connection
314
405
315
406
Like MQTT bridge, the Event Hubs connector acts as a client to the IoT MQ MQTT broker. If you've customized the listener port and/or authentication of your IoT MQ MQTT broker, override the local MQTT connection configuration for the Event Hubs connector as well. To learn more, see [MQTT bridge local broker connection](howto-configure-mqtt-bridge.md).
@@ -326,7 +417,7 @@ metadata:
326
417
namespace: <SAME NAMESPACE AS BROKER> # For example "default"
327
418
spec:
328
419
kafkaConnectorRef: my-eh-connector
329
-
compression: snappy
420
+
compression: none
330
421
batching:
331
422
enabled: true
332
423
latencyMs: 1000
@@ -369,14 +460,14 @@ The following table describes the fields in the KafkaConnectorTopicMap CR:
369
460
370
461
### Compression
371
462
372
-
The compression field enables compression for the messages sent to Kafka topics. Compression helps to reduce the network bandwidth and storage space required for data transfer. However, compression also adds some overhead and latency to the process. The supported compression types are listed in the following table.
463
+
The compression field enables compression for the messages sent to Kafka topics. Compression helps to reduce the network bandwidth and storage space required for data transfer. However, compression also adds some overhead and latency to the process. The compression types values and support are listed in the following table.
373
464
374
-
| Value | Description |
375
-
| ----- | ----------- |
376
-
| none | No compression or batching is applied. *none* is the default value if no compression is specified. |
377
-
| gzip | GZIP compression and batching are applied. GZIP is a general-purpose compression algorithm that offers a good balance between compression ratio and speed. |
378
-
| snappy | Snappy compression and batching are applied. Snappy is a fast compression algorithm that offers moderate compression ratio and speed. |
379
-
| lz4 | LZ4 compression and batching are applied. LZ4 is a fast compression algorithm that offers low compression ratio and high speed. |
465
+
| Value | Description | Supported |
466
+
| ----- | ----------- | --------- |
467
+
| none | No compression or batching is applied. *none* is the default value if no compression is specified. | Yes |
468
+
| gzip | GZIP compression and batching are applied. GZIP is a general-purpose compression algorithm that offers a good balance between compression ratio and speed. | Yes. [Event Hubs Premium](../../event-hubs/event-hubs-premium-overview.md) pricing tier is required for GZIP compression. |
469
+
| snappy | Snappy compression and batching are applied. Snappy is a fast compression algorithm that offers moderate compression ratio and speed. | Not supported by [Azure Event Hubs](../../event-hubs/azure-event-hubs-kafka-overview.md#compression). Use [Apache Kafka](https://kafka.apache.org). |
470
+
| lz4 | LZ4 compression and batching are applied. LZ4 is a fast compression algorithm that offers low compression ratio and high speed. | Not supported by [Azure Event Hubs](../../event-hubs/azure-event-hubs-kafka-overview.md#compression). Use [Apache Kafka](https://kafka.apache.org). |
380
471
381
472
### Batching
382
473
@@ -476,7 +567,7 @@ kafkaToMqtt:
476
567
qos: 0
477
568
```
478
569
479
-
In this example, messages from Kafka topic *sending-event-hub** are published to MQTT topic *heater-commands* with QoS level 0.
570
+
In this example, messages from Kafka topic *sending-event-hub* are published to MQTT topic *heater-commands* with QoS level 0.
0 commit comments