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
Copy file name to clipboardExpand all lines: articles/iot-operations/create-edge-apps/howto-develop-mqttnet-apps.md
+12-13Lines changed: 12 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,25 @@
1
1
---
2
-
title: Use MQTTnet to develop distributed application workloads
3
-
description: Develop distributed applications that talk with MQTT broker using MQTTnet.
2
+
title: Develop distributed application workloads with MQTTnet
3
+
description: Learn how to develop distributed applications using MQTTnet to connect with MQTT broker.
4
4
author: PatAltimore
5
5
ms.author: patricka
6
6
ms.subservice: azure-mqtt-broker
7
7
ms.topic: how-to
8
8
ms.custom:
9
9
- ignite-2023
10
-
ms.date: 10/22/2024
10
+
ms.date: 05/07/2025
11
11
12
12
#CustomerIntent: As an developer, I want to understand how to use MQTTnet to develop distributed apps that talk with MQTT broker.
13
13
ms.service: azure-iot-operations
14
14
---
15
15
16
-
# Use MQTTnet to develop distributed application workloads that connect to MQTT broker
16
+
# Develop distributed application workloads with MQTTnet
17
17
18
-
[MQTTnet](https://dotnet.github.io/MQTTnet/) is an open-source, high performance .NET library for MQTT based communication. This article uses a Kubernetes service account token and MQTTnet to connect to MQTT broker. You should use service account tokens to connect in-cluster applications.
18
+
[MQTTnet](https://dotnet.github.io/MQTTnet/) is an open-source, high performance .NET library for MQTT based communication. This article explains how to use a Kubernetes service account token and MQTTnet to connect to MQTT broker. Use service account tokens to connect in-cluster applications.
19
19
20
20
## Sample code
21
21
22
-
The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/main/samples/mqtt-client-dotnet/Program.cs)performs the following steps:
22
+
The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/main/samples/mqtt-client-dotnet/Program.cs)does the following:
23
23
24
24
1. Creates an MQTT client using the `MqttFactory` class:
25
25
@@ -28,16 +28,15 @@ The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/m
28
28
varmqttClient=mqttFactory.CreateMqttClient();
29
29
```
30
30
31
-
1. The [Kubernetespodspecification](#pod-specification) mountstheserviceaccountonthecontainerfilesystem. Thecontentsofthefileareread:
32
-
##3. The mounted token is used as the password with well-known username `K8S-SAT`:
31
+
1. The [Kubernetespodspecification](#pod-specification) mountstheserviceaccountonthecontainerfilesystem, andthefilecontentsareread. Themountedtokenisusedasthepasswordwiththewellknownusername `K8S-SAT`:
1. TheMQTTclientoptionsareconfiguredusingthe `MqttClientOptions` class. Usingthe`MqttClientOptionsBuilder` asadvisedinthe [client](https://github.com/dotnet/MQTTnet/wiki/Client) documentation is the advised way of setting the options:
39
+
1. TheMQTTclientoptionsareconfiguredusingthe `MqttClientOptions` class. The`MqttClientOptionsBuilder`,asrecommendedinthe [client](https://github.com/dotnet/MQTTnet/wiki/Client) documentation, is the preferred way to set the options:
@@ -66,7 +65,7 @@ The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/m
66
65
67
66
## Pod specification
68
67
69
-
The `serviceAccountName` fieldinthepodconfigurationmustmatchtheserviceaccountassociatedwiththetokenbeingused. Also, notethe `serviceAccountToken.expirationSeconds` issetto **86400 seconds**, andonceitexpires, youneedtoreloadthetokenfromdisk. Thislogicisn't implemented in this sample.
68
+
The `serviceAccountName` fieldinthepodconfigurationmustmatchtheserviceaccountassociatedwiththetokenbeingused. Also, notethatthe `serviceAccountToken.expirationSeconds` issetto **86400 seconds**, andwhenitexpires, youneedtoreloadthetokenfromdisk. Thislogicisn't implemented in this sample.
70
69
71
70
```yaml
72
71
apiVersion:v1
@@ -86,7 +85,7 @@ spec:
86
85
87
86
volumes:
88
87
89
-
# SAT token used to authenticate between the application and the MQTT broker
88
+
# The SAT token authenticates the application with the MQTT broker
90
89
-name:mqtt-client-token
91
90
projected:
92
91
sources:
@@ -121,7 +120,7 @@ spec:
121
120
value:"/var/run/secrets/tokens/mqtt-client-token"
122
121
```
123
122
124
-
To run the sample, follow the instructions in its [README](https://github.com/Azure-Samples/explore-iot-operations/tree/main/samples/mqtt-client-dotnet).
123
+
Run the sample by following the instructions in its [README](https://github.com/Azure-Samples/explore-iot-operations/tree/main/samples/mqtt-client-dotnet).
Copy file name to clipboardExpand all lines: articles/iot-operations/manage-mqtt-broker/overview-broker.md
+29-27Lines changed: 29 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,31 @@
1
1
---
2
-
title: Publish and subscribe MQTT messages using MQTT broker
2
+
title: Publish and Subscribe MQTT Messages Using Azure MQTT Broker
3
3
description: Use MQTT broker to publish and subscribe to messages. Destinations include other MQTT brokers, data flows, and Azure cloud services.
4
+
#customer intent: As a solution architect, I want to learn about the architecture of the Azure MQTT Broker so that I can design fault-tolerant and scalable IoT solutions.
4
5
author: PatAltimore
5
6
ms.author: patricka
6
7
ms.subservice: azure-mqtt-broker
7
8
ms.topic: conceptual
8
9
ms.custom:
9
10
- ignite-2023
10
-
ms.date: 11/04/2024
11
-
12
-
#CustomerIntent: As an operator, I want to understand how I can use MQTT broker to publish and subscribe to MQTT topics.
Azure IoT Operations features an MQTT broker that's enterprise grade and compliant with standards. The MQTT broker is scalable, highly available, and Kubernetes-native. It provides the messaging plane for IoT Operations, enables bidirectional edge/cloud communication, and powers[event-driven applications](/azure/architecture/guide/architecture-styles/event-driven) at the edge.
22
+
Azure IoT Operations includes an MQTT broker that's enterprise grade and standards compliant. The MQTT broker is scalable, highly available, and Kubernetesnative. It provides the messaging plane for IoT Operations, enables bidirectional edge-to-cloud communication, and supports[event-driven applications](/azure/architecture/guide/architecture-styles/event-driven) at the edge.
21
23
22
24
## MQTT compliance
23
25
24
-
MQTT has emerged as the common language that's used among protocols in the IoT space. MQTT's simple design allows a single broker to serve tens of thousands of clients simultaneously, with lightweight publish-subscribe topic creation and management. Many IoT devices support MQTT natively out of the box. Downstream translation gateways rationalize the long tail of IoT protocols into MQTT.
26
+
MQTT is a common protocol in the IoT space. Its simple design lets a single broker serve thousands of clients simultaneously with lightweight publish-subscribe topic creation and management. Many IoT devices natively support MQTT. Downstream translation gateways convert various IoT protocols into MQTT.
25
27
26
-
The MQTT broker underpins the messaging layer in IoT Operations and supports both MQTT v3.1.1 and MQTT v5. For more information about supported MQTT features, see [MQTT feature support in MQTT broker](../reference/mqtt-support.md).
28
+
The MQTT broker supports the messaging layer in IoT Operations and is compatible with MQTT v3.1.1 and MQTT v5. For more information about supported MQTT features, see [MQTT feature support in MQTT broker](../reference/mqtt-support.md).
27
29
28
30
## Architecture
29
31
@@ -32,26 +34,26 @@ The MQTT broker has two major layers:
32
34
- Stateless frontend layer
33
35
- Stateful and sharded backend layer
34
36
35
-
The frontend layer handles client connections and requests and routes them to the backend. The backend layer partitions data by different keys, such as a client ID for client sessions and a topic name for topic messages. It uses chain replication to replicate data within each partition.
37
+
The frontend layer handles client connections and requests, and it routes them to the backend. The backend layer partitions data by keys, like a client ID for client sessions and a topic name for topic messages. The backend layer uses chain replication to copy data within each partition.
36
38
37
39
The goals of the architecture are:
38
40
39
-
-**Fault tolerance and isolation**: Message publishing continues if backend pods fail and prevents failures from propagating to the rest of the system.
41
+
-**Fault tolerance and isolation**: Message publishing continues if backend pods fail, and failures don't propagate to the rest of the system.
40
42
-**Failure recovery**: Automatic failure recovery without operator intervention.
41
-
-**No message loss**: Delivery of messages if at least one frontend pod and one backend pod in a partition is running.
42
-
-**Elastic scaling**: Horizontal scaling of publishing and subscribing throughput to support edge and cloud deployments.
43
-
-**Consistent performance at scale**: Limit message latency overhead because of chain replication.
44
-
-**Operational simplicity**: Minimum dependency on external components to simplify maintenance and complexity.
43
+
-**No message loss**: Messages are delivered if at least one frontend pod and one backend pod in a partition are running.
44
+
-**Elastic scaling**: Horizontal scaling of publishing and subscribing throughput supports edge and cloud deployments.
45
+
-**Consistent performance at scale**: Limits message latency overhead due to chain replication.
46
+
-**Operational simplicity**: Reduces dependency on external components to simplify maintenance and complexity.
45
47
46
48
## Configuration
47
49
48
-
For configuration, the MQTT broker is composed of several Kubernetes custom resources that define different aspects of the broker's behavior and functionality:
50
+
For configuration, the MQTT broker uses several Kubernetes custom resources to define different aspects of the broker's behavior and functionality:
49
51
50
52
- The main resource is [Broker](/rest/api/iotoperations/broker), which defines the global settings like cardinality, memory usage profile, and diagnostic settings.
51
53
- A Broker resource can have up to three [BrokerListeners](/rest/api/iotoperations/broker-listener), each of which listens for incoming MQTT connections on the specified service type (`NodePort`, `LoadBalancer`, or `ClusterIP`). Each BrokerListener resource can have multiple ports.
52
54
- Each port within a BrokerListener resource can be associated with a [BrokerAuthentication](/rest/api/iotoperations/broker-authentication) resource and a [BrokerAuthorization](/rest/api/iotoperations/broker-authorization) resource. These authentication and authorization policies determine which clients can connect to the port and what actions they can perform on the broker.
53
55
54
-
The relationship between Broker and BrokerListener is *one-to-many*. The relationship between BrokerListener and BrokerAuthentication/BrokerAuthorization is *many-to-many*. The entity relationship diagram for these resources is:
56
+
The relationship between Broker and BrokerListener is *one-to-many*, while the relationship between BrokerListener and BrokerAuthentication/BrokerAuthorization is *many-to-many*. The entity relationship diagram for these resources is:
55
57
56
58
<!-- ```mermaid
57
59
erDiagram
@@ -89,11 +91,11 @@ erDiagram
89
91
:::image type="content" source="media/overview-broker/default-broker-resources.svg" alt-text="Diagram that shows the default broker resources and relationships between them.":::
90
92
91
93
> [!IMPORTANT]
92
-
> To prevent unintentional disruption with communication between IoT Operations internal components, we recommend that you don't modify any default configuration.
94
+
> To avoid disrupting communication between IoT Operations internal components, don't modify any default configuration.
93
95
>
94
-
> To customize the MQTT broker deployment, *add* new resources like BrokerListeners, BrokerAuthentication, and BrokerAuthorization to the default Broker.
96
+
> To customize the MQTT broker deployment, add new resources such as BrokerListeners, BrokerAuthentication, and BrokerAuthorization to the default Broker.
95
97
>
96
-
> The Broker resource itself is immutable and can't be modified after deployment, but it only needs customization in advanced scenarios. To learn more about customizing the Broker resource, see [Customize default Broker](#customize-default-broker).
98
+
> The Broker resource is immutable and can't be modified after deployment, but it requires customization only in advanced scenarios. To learn more about customizing the Broker resource, see [Customize default Broker](#customize-default-broker).
97
99
98
100
In a full deployment, you could have multiple BrokerListeners, each with multiple ports, and each port could have different BrokerAuthentication and BrokerAuthorization resources associated with it.
99
101
@@ -104,7 +106,7 @@ For example, starting from the default setup, you add:
104
106
- A BrokerAuthentication resource named *example-authn*, with a custom authentication method.
105
107
- A BrokerAuthorization resource named *example-authz*, with your custom authorization settings.
106
108
107
-
Then, if you configure all the new ports by using the same BrokerAuthentication and BrokerAuthorization resources, the setup looks like:
109
+
If you configure all the new ports with the same BrokerAuthentication and BrokerAuthorization resources, the setup looks like this:
108
110
109
111
<!-- ```mermaid
110
112
erDiagram
@@ -165,18 +167,18 @@ erDiagram
165
167
166
168
:::image type="content" source="media/overview-broker/full-broker-deployment-resources.svg" alt-text="Diagram that shows a full custom broker deployment and relationships between each.":::
167
169
168
-
This way, you keep the default setup intact and add new resources to customize the MQTT broker deployment to your needs.
170
+
This approach keeps the default setup intact and lets you add new resources to customize the MQTT broker deployment.
169
171
170
172
## Default Broker resource
171
173
172
-
Each IoT Operations deployment can have only one Broker, and it must be named *default*. The default Broker resource is required for IoT Operations to function. It's immutable and can't be modified after deployment.
174
+
Each IoT Operations deployment can have only one broker, and it must be named *default*. The default broker resource is required for IoT Operations to function. It's immutable and can't be modified after deployment.
173
175
174
176
> [!CAUTION]
175
-
> Don't delete the default Broker resource. Doing so disrupts communication between IoT Operations internal components, and the deployment stops functioning.
177
+
> Don't delete the default broker resource. Doing so disrupts communication between IoT Operations internal components, and the deployment stops functioning.
176
178
177
179
### Customize default Broker
178
180
179
-
Customizing the default Broker resource isn't required for most setups. The settings that require customization include:
181
+
Customizing the default broker resource isn't required for most setups. The settings that require customization include:
180
182
181
183
-[Cardinality](./howto-configure-availability-scale.md#configure-scaling-settings): Determines the broker's capacity to handle more connections and messages, and it enhances high availability if there are pod or node failures.
182
184
-[Memory profile](./howto-configure-availability-scale.md#configure-memory-profile): Sets the maximum memory usage of the broker and how to handle memory usage as the broker scales up.
@@ -185,7 +187,7 @@ Customizing the default Broker resource isn't required for most setups. The sett
185
187
-[Advanced MQTT client options](./howto-broker-mqtt-client-options.md): Configuration for advanced MQTT client options like session expiry, message expiry, and keep-alive settings.
186
188
-[Encryption of internal traffic](./howto-encrypt-internal-traffic.md): Configuration for encrypting internal traffic between broker frontend and backend pods.
187
189
188
-
You can customize the default broker only during initial deployment time, by using the Azure CLI or the Azure portal. A new deployment is required if you need different Broker configuration settings.
190
+
You can customize the default broker only during the initial deployment, by using the Azure CLI or the Azure portal. A new deployment is required if you need different broker configuration settings.
189
191
190
192
To customize the default Broker during deployment:
191
193
@@ -195,7 +197,7 @@ When you follow the guide to [deploy IoT Operations](../deploy-iot-ops/howto-dep
195
197
196
198
# [Azure CLI](#tab/azure-cli)
197
199
198
-
To configure settings like disk-backed message buffer and advanced MQTT client options, use the `--broker-config-file` flag during `az iot ops create`. To learn more, see [Azure CLI support for advanced MQTT broker configuration](https://aka.ms/aziotops-broker-config).
200
+
To configure settings like the disk-backed message buffer and advanced MQTT client options, use the `--broker-config-file` flag during `az iot ops create`. To learn more, see [Azure CLI support for advanced MQTT broker configuration](https://aka.ms/aziotops-broker-config).
199
201
200
202
# [Bicep](#tab/bicep)
201
203
@@ -208,13 +210,13 @@ Use the Azure portal or the Azure CLI to customize the default Broker resource.
208
210
---
209
211
210
212
> [!IMPORTANT]
211
-
> You can't update the broker resource after the initial deployment. Configuration changes to cardinality, memory profile, or disk buffer aren't allowed post-deployment.
213
+
> You can't update the broker resource after the initial deployment. Configuration changes to cardinality, memory profile, or the disk buffer aren't allowed post-deployment.
212
214
>
213
215
> As a workaround, when deploying Azure IoT Operations with the [az iot ops init](/cli/azure/iot/ops#az-iot-ops-init) command, you can include the `--broker-config-file` parameter with a JSON configuration file for the MQTT broker. For more information, see [Advanced MQTT broker config](https://github.com/Azure/azure-iot-ops-cli-extension/wiki/Advanced-Mqtt-Broker-Config) and [Configure core MQTT broker settings](../manage-mqtt-broker/howto-configure-availability-scale.md).
0 commit comments