Skip to content

Commit 01c14c2

Browse files
committed
Freshness review
1 parent bcf0cb8 commit 01c14c2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

articles/iot-operations/create-edge-apps/howto-develop-mqttnet-apps.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
---
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.
44
author: PatAltimore
55
ms.author: patricka
66
ms.subservice: azure-mqtt-broker
77
ms.topic: how-to
88
ms.custom:
99
- ignite-2023
10-
ms.date: 10/22/2024
10+
ms.date: 05/07/2025
1111

1212
#CustomerIntent: As an developer, I want to understand how to use MQTTnet to develop distributed apps that talk with MQTT broker.
1313
ms.service: azure-iot-operations
1414
---
1515

16-
# Use MQTTnet to develop distributed application workloads that connect to MQTT broker
16+
# Develop distributed application workloads with MQTTnet
1717

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.
1919

2020
## Sample code
2121

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:
2323

2424
1. Creates an MQTT client using the `MqttFactory` class:
2525

@@ -28,16 +28,16 @@ The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/m
2828
var mqttClient = mqttFactory.CreateMqttClient();
2929
```
3030

31-
1. The [Kubernetes pod specification](#pod-specification) mounts the service account on the container file system. The contents of the file are read:
32-
##3. The mounted token is used as the password with well-known username `K8S-SAT`:
31+
1. The [Kubernetes pod specification](#pod-specification) mounts the service account on the container file system, and the file contents are read:
32+
##3. The mounted token is used as the password with the well known username `K8S-SAT`:
3333

3434
```csharp
3535
static string sat_auth_file = "/var/run/secrets/tokens/mqtt-client-token";
3636
...
3737
var satToken = File.ReadAllBytes(sat_auth_file);
3838
```
3939

40-
1. The MQTT client options are configured using the `MqttClientOptions` class. Using the `MqttClientOptionsBuilder` as advised in the [client](https://github.com/dotnet/MQTTnet/wiki/Client) documentation is the advised way of setting the options:
40+
1. The MQTT client options are configured using the `MqttClientOptions` class. The `MqttClientOptionsBuilder`, as recommended in the [client](https://github.com/dotnet/MQTTnet/wiki/Client) documentation, is the preferred way to set the options:
4141
4242
```csharp
4343
var mqttClientOptions = new MqttClientOptionsBuilder()
@@ -53,7 +53,7 @@ The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/m
5353
var response = await mqttClient.ConnectAsync(mqttClientOptions.Build(), CancellationToken.None);
5454
```
5555

56-
6. MQTT messages can be created using the properties directly or using `MqttApplicationMessageBuilder`. This class has overloads that allow dealing with different payload formats. The API of the builder is a fluent API. The following code shows how to compose an application message and publish them to an article called *sampletopic*:
56+
1. Create MQTT messages using properties directly or with `MqttApplicationMessageBuilder`. This class provides overloads for handling different payload formats. The builder API uses a fluent design. The following code shows how to compose an application message and publish it to a topic called *sampletopic*:
5757

5858
```csharp
5959
var applicationMessage = new MqttApplicationMessageBuilder()
@@ -66,7 +66,7 @@ The [sample code](https://github.com/Azure-Samples/explore-iot-operations/tree/m
6666

6767
## Pod specification
6868

69-
The `serviceAccountName` field in the pod configuration must match the service account associated with the token being used. Also, note the `serviceAccountToken.expirationSeconds` is set to **86400 seconds**, and once it expires, you need to reload the token from disk. This logic isn't implemented in this sample.
69+
The `serviceAccountName` field in the pod configuration must match the service account associated with the token being used. Also, note that the `serviceAccountToken.expirationSeconds` is set to **86400 seconds**, and when it expires, you need to reload the token from disk. This logic isn't implemented in this sample.
7070

7171
```yaml
7272
apiVersion: v1
@@ -86,7 +86,7 @@ spec:
8686

8787
volumes:
8888

89-
# SAT token used to authenticate between the application and the MQTT broker
89+
# The SAT token authenticates the application with the MQTT broker
9090
- name: mqtt-client-token
9191
projected:
9292
sources:
@@ -121,7 +121,7 @@ spec:
121121
value: "/var/run/secrets/tokens/mqtt-client-token"
122122
```
123123

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).
124+
Run the sample by following the instructions in its [README](https://github.com/Azure-Samples/explore-iot-operations/tree/main/samples/mqtt-client-dotnet).
125125

126126
## Related content
127127

0 commit comments

Comments
 (0)