Skip to content

Commit e3bb4fa

Browse files
committed
Make tutorial accurate
1 parent a886908 commit e3bb4fa

File tree

2 files changed

+64
-79
lines changed

2 files changed

+64
-79
lines changed

articles/iot-operations/connect-to-cloud/howto-configure-mqtt-endpoint.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ MQTT dataflow endpoints are used for MQTT sources and destinations. You can conf
2323
- An instance of [Azure IoT Operations Preview](../deploy-iot-ops/howto-deploy-iot-operations.md)
2424
- A [configured dataflow profile](howto-configure-dataflow-profile.md)
2525

26-
## Azure IoT Operations Local MQTT broker
26+
## Azure IoT Operations local MQTT broker
2727

2828
### Default endpoint
2929

articles/iot-operations/connect-to-cloud/tutorial-mqtt-bridge.md

Lines changed: 63 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Using Azure CLI, find the principal ID for the Azure IoT Operations Arc extensio
9292
```azurecli
9393
export PRINCIPAL_ID=$(az k8s-extension list \
9494
--resource-group $RESOURCE_GROUP \
95-
--cluster-name <CLUSTER-NAME> \
95+
--cluster-name $CLUSTER_NAME \
9696
--cluster-type connectedClusters \
9797
--query "[?extensionType=='microsoft.iotoperations'].identity.principalId | [0]" -o tsv)
9898
echo $PRINCIPAL_ID
@@ -145,77 +145,34 @@ Take note of the output value for `topicSpacesConfiguration.hostname` that is a
145145
example.region-1.ts.eventgrid.azure.net
146146
```
147147

148-
## Create an Azure IoT Operations MQTT broker dataflow endpoint
148+
## Understand the default Azure IoT Operations MQTT broker dataflow endpoint
149149

150-
# [Bicep](#tab/bicep)
151-
152-
The dataflow and dataflow endpoints for MQTT broker and Azure Event Grid can be deployed as standard Azure resources since they have Azure Resource Provider (RPs) implementations. This Bicep template file from [Bicep File for MQTT-bridge dataflow Tutorial](https://github.com/Azure-Samples/explore-iot-operations/blob/main/samples/quickstarts/dataflow.bicep) deploys the necessary dataflow and dataflow endpoints.
153-
154-
Download the file to your local, and make sure to replace the values for `customLocationName`, `aioInstanceName`, `eventGridHostName` with yours.
150+
By default, Azure IoT Operations deploys an MQTT broker as well as an MQTT broker dataflow endpoint. The MQTT broker dataflow endpoint is used to connect to the MQTT broker. The default configuration uses the built-in service account token for authentication. The endpoint is named `default` and is available in the same namespace as Azure IoT Operations. The endpoint is used as the source for the dataflows you create in the next steps.
155151

156-
Next, execute the following command in your terminal:
152+
To learn more about the default MQTT broker dataflow endpoint, see [Azure IoT Operations local MQTT broker default endpoint](../connect-to-cloud/howto-configure-mqtt-endpoint.md#default-endpoint).
157153

158-
```azurecli
159-
az stack group create --name MyDeploymentStack --resource-group $RESOURCE_GROUP --template-file /workspaces/explore-iot-operations/mqtt-bridge.bicep --action-on-unmanage 'deleteResources' --deny-settings-mode 'none' --yes
160-
```
161-
This endpoint is the source for the dataflow that sends messages to Azure Event Grid.
162-
163-
```bicep
164-
resource MqttBrokerDataflowEndpoint 'Microsoft.IoTOperations/instances/dataflowEndpoints@2024-08-15-preview' = {
165-
parent: aioInstance
166-
name: 'aiomq'
167-
extendedLocation: {
168-
name: customLocation.id
169-
type: 'CustomLocation'
170-
}
171-
properties: {
172-
endpointType: 'Mqtt'
173-
mqttSettings: {
174-
authentication: {
175-
method: 'ServiceAccountToken'
176-
serviceAccountTokenSettings: {
177-
audience: 'aio-internal'
178-
}
179-
}
180-
host: 'aio-broker:18883'
181-
tls: {
182-
mode: 'Enabled'
183-
trustedCaCertificateConfigMapRef: 'azure-iot-operations-aio-ca-trust-bundle'
184-
}
185-
}
186-
}
187-
}
188-
```
189-
190-
# [Kubernetes](#tab/kubernetes)
191-
192-
Create dataflow endpoint for the Azure IoT Operations built-in MQTT broker. This endpoint is the source for the dataflow that sends messages to Azure Event Grid.
154+
## Create an Azure Event Grid dataflow endpoint
193155

194-
```yaml
195-
apiVersion: connectivity.iotoperations.azure.com/v1beta1
196-
kind: DataflowEndpoint
197-
metadata:
198-
name: mq
199-
namespace: azure-iot-operations
200-
spec:
201-
endpointType: Mqtt
202-
mqttSettings:
203-
authentication:
204-
method: ServiceAccountToken
205-
serviceAccountTokenSettings: {}
206-
```
156+
Create dataflow endpoint for the Azure Event Grid. This endpoint is the destination for the dataflow that sends messages to Azure Event Grid. Replace `<EVENT_GRID_HOSTNAME>` with the MQTT hostname you got from the previous step. Include the port number `8883`.
207157

208-
---
158+
# [Bicep](#tab/bicep)
209159

210-
This is the default configuration for the Azure IoT Operations MQTT broker endpoint. The authentication method is set to `ServiceAccountToken` to use the built-in service account token for authentication.
160+
The dataflow and dataflow endpoints Azure Event Grid can be deployed as standard Azure resources since they have Azure Resource Provider (RPs) implementations. This Bicep template file from [Bicep File for MQTT-bridge dataflow Tutorial](https://github.com/Azure-Samples/explore-iot-operations/blob/main/samples/quickstarts/dataflow.bicep) deploys the necessary dataflow and dataflow endpoints.
211161

212-
## Create an Azure Event Grid dataflow endpoint
162+
Download the file to your local, and make sure to replace the values for `customLocationName`, `aioInstanceName`, `eventGridHostName` with yours.
213163

214-
# [Bicep](#tab/bicep)
164+
```bicep
165+
param customLocationName string = '<CUSTOM_LOCATION_NAME>'
166+
param aioInstanceName string = '<AIO_INSTANCE_NAME>'
167+
param eventGridHostName string = '<EVENT_GRID_HOSTNAME>:8883'
215168
216-
Since you already deployed the resources in the previous section, there's no additional deployment needed. However, this endpoint is the destination for the dataflow that sends messages to Azure Event Grid. Replace `<EVENT-GRID-HOSTNAME>` with the hostname you got from the previous step. Include the port number `8883`.
169+
resource customLocation 'Microsoft.ExtendedLocation/customLocations@2021-08-31-preview' existing = {
170+
name: customLocationName
171+
}
217172
218-
```bicep
173+
resource aioInstance 'Microsoft.IoTOperations/instances@2024-08-15-preview' existing = {
174+
name: aioInstanceName
175+
}
219176
resource remoteMqttBrokerDataflowEndpoint 'Microsoft.IoTOperations/instances/dataflowEndpoints@2024-08-15-preview' = {
220177
parent: aioInstance
221178
name: 'eventgrid'
@@ -230,7 +187,7 @@ resource remoteMqttBrokerDataflowEndpoint 'Microsoft.IoTOperations/instances/dat
230187
method: 'SystemAssignedManagedIdentity'
231188
systemAssignedManagedIdentitySettings: {}
232189
}
233-
host: '<NAMESPACE>.<REGION>-1.ts.eventgrid.azure.net:8883'
190+
host: eventGridHostName
234191
tls: {
235192
mode: 'Enabled'
236193
}
@@ -239,9 +196,13 @@ resource remoteMqttBrokerDataflowEndpoint 'Microsoft.IoTOperations/instances/dat
239196
}
240197
```
241198

242-
# [Kubernetes](#tab/kubernetes)
199+
Next, execute the following command in your terminal. Replace `<FILE>` with the name of the Bicep file you downloaded.
243200

244-
Create dataflow endpoint for the Azure Event Grid. This endpoint is the destination for the dataflow that sends messages to Azure Event Grid. Replace `<EVENT-GRID-HOSTNAME>` with the hostname you got from the previous step. Include the port number `8883`.
201+
```azurecli
202+
az stack group create --name DeployDataflowEndpoint --resource-group $RESOURCE_GROUP --template-file <FILE>.bicep --action-on-unmanage 'deleteResources' --deny-settings-mode 'none' --yes
203+
```
204+
205+
# [Kubernetes](#tab/kubernetes)
245206

246207
```yaml
247208
apiVersion: connectivity.iotoperations.azure.com/v1beta1
@@ -252,7 +213,7 @@ metadata:
252213
spec:
253214
endpointType: Mqtt
254215
mqttSettings:
255-
host: <EVENT-GRID-HOSTNAME>:8883
216+
host: <EVENT_GRID_HOSTNAME>:8883
256217
authentication:
257218
method: SystemAssignedManagedIdentity
258219
systemAssignedManagedIdentitySettings: {}
@@ -268,11 +229,24 @@ Since the Event Grid MQTT broker requires TLS, the `tls` setting is enabled. No
268229

269230
## Create dataflows
270231

271-
# [Bicep](#tab/bicep)
232+
Create two dataflows with the Azure IoT Operations MQTT broker endpoint as the source and the Azure Event Grid endpoint as the destination, and vice versa. No need to configure transformation.
272233

273-
In this example, there are two dataflows with the Azure IoT Operations MQTT broker endpoint as the source and the Azure Event Grid endpoint as the destination, and vice versa. No need to configure transformation.
234+
# [Bicep](#tab/bicep)
274235

275236
```bicep
237+
param customLocationName string = '<CUSTOM_LOCATION_NAME>'
238+
param aioInstanceName string = '<AIO_INSTANCE_NAME>'
239+
240+
resource customLocation 'Microsoft.ExtendedLocation/customLocations@2021-08-31-preview' existing = {
241+
name: customLocationName
242+
}
243+
resource aioInstance 'Microsoft.IoTOperations/instances@2024-08-15-preview' existing = {
244+
name: aioInstanceName
245+
}
246+
resource defaultDataflowProfile 'Microsoft.IoTOperations/instances/dataflowProfiles@2024-08-15-preview' existing = {
247+
parent: aioInstance
248+
name: 'default'
249+
}
276250
resource dataflow_1 'Microsoft.IoTOperations/instances/dataflowProfiles/dataflows@2024-08-15-preview' = {
277251
parent: defaultDataflowProfile
278252
name: 'local-to-remote'
@@ -286,15 +260,15 @@ resource dataflow_1 'Microsoft.IoTOperations/instances/dataflowProfiles/dataflow
286260
{
287261
operationType: 'Source'
288262
sourceSettings: {
289-
endpointRef: MqttBrokerDataflowEndpoint.name
263+
endpointRef: 'default'
290264
dataSources: array('tutorial/local')
291265
}
292266
}
293267
{
294268
operationType: 'Destination'
295269
destinationSettings: {
296270
endpointRef: remoteMqttBrokerDataflowEndpoint.name
297-
dataDestination: 'telemetry/iot-mq'
271+
dataDestination: 'telemetry/aio'
298272
}
299273
}
300274
]
@@ -323,7 +297,7 @@ resource dataflow_2 'Microsoft.IoTOperations/instances/dataflowProfiles/dataflow
323297
{
324298
operationType: 'Destination'
325299
destinationSettings: {
326-
endpointRef: MqttBrokerDataflowEndpoint.name
300+
endpointRef: 'default'
327301
dataDestination: 'tutorial/cloud'
328302
}
329303
}
@@ -332,9 +306,14 @@ resource dataflow_2 'Microsoft.IoTOperations/instances/dataflowProfiles/dataflow
332306
}
333307
```
334308

309+
Like the dataflow endpoint, execute the following command in your terminal:
310+
311+
```azurecli
312+
az stack group create --name DeployDataflows --resource-group $RESOURCE_GROUP --template-file <FILE>.bicep --action-on-unmanage 'deleteResources' --deny-settings-mode 'none' --yes
313+
```
314+
335315
# [Kubernetes](#tab/kubernetes)
336316

337-
Create two dataflows with the Azure IoT Operations MQTT broker endpoint as the source and the Azure Event Grid endpoint as the destination, and vice versa. No need to configure transformation.
338317

339318
```yaml
340319
apiVersion: connectivity.iotoperations.azure.com/v1beta1
@@ -347,13 +326,13 @@ spec:
347326
operations:
348327
- operationType: Source
349328
sourceSettings:
350-
endpointRef: mq
329+
endpointRef: default
351330
dataSources:
352331
- tutorial/local
353332
- operationType: Destination
354333
destinationSettings:
355334
endpointRef: eventgrid
356-
dataDestination: telemetry/iot-mq
335+
dataDestination: telemetry/aio
357336
---
358337
apiVersion: connectivity.iotoperations.azure.com/v1beta1
359338
kind: Dataflow
@@ -370,7 +349,7 @@ spec:
370349
- telemetry/#
371350
- operationType: Destination
372351
destinationSettings:
373-
endpointRef: mq
352+
endpointRef: default
374353
dataDestination: tutorial/cloud
375354
```
376355

@@ -383,10 +362,10 @@ Together, the two dataflows form an MQTT bridge, where you:
383362
* Use TLS for both remote and local brokers
384363
* Use system-assigned managed identity for authentication to the remote broker
385364
* Use Kubernetes service account for authentication to the local broker
386-
* Use the topic map to map the `tutorial/local` topic to the `telemetry/iot-mq` topic on the remote broker
365+
* Use the topic map to map the `tutorial/local` topic to the `telemetry/aio` topic on the remote broker
387366
* Use the topic map to map the `telemetry/#` topic on the remote broker to the `tutorial/cloud` topic on the local broker
388367

389-
When you publish to the `tutorial/local` topic on the local Azure IoT Operations MQTT broker, the message is bridged to the `telemetry/iot-mq` topic on the remote Event Grid MQTT broker. Then, the message is bridged back to the `tutorial/cloud` topic (because the `telemetry/#` wildcard topic captures it) on the local Azure IoT Operations MQTT broker. Similarly, when you publish to the `telemetry/iot-mq` topic on the remote Event Grid MQTT broker, the message is bridged to the `tutorial/cloud` topic on the local Azure IoT Operations MQTT broker.
368+
When you publish to the `tutorial/local` topic on the local Azure IoT Operations MQTT broker, the message is bridged to the `telemetry/aio` topic on the remote Event Grid MQTT broker. Then, the message is bridged back to the `tutorial/cloud` topic (because the `telemetry/#` wildcard topic captures it) on the local Azure IoT Operations MQTT broker. Similarly, when you publish to the `telemetry/aio` topic on the remote Event Grid MQTT broker, the message is bridged to the `tutorial/cloud` topic on the local Azure IoT Operations MQTT broker.
390369

391370
## Deploy MQTT client
392371

@@ -404,14 +383,20 @@ Currently, bicep doesn't apply to deploy MQTT client.
404383

405384
```yaml
406385
apiVersion: v1
386+
kind: ServiceAccount
387+
metadata:
388+
name: mqtt-client
389+
namespace: azure-iot-operations
390+
---
391+
apiVersion: v1
407392
kind: Pod
408393
metadata:
409394
name: mqtt-client
410395
# Namespace must match MQTT broker BrokerListener's namespace
411396
# Otherwise use the long hostname: aio-broker.azure-iot-operations.svc.cluster.local
412397
namespace: azure-iot-operations
413398
spec:
414-
# Use the "mqtt-client" service account which comes with default deployment
399+
# Use the "mqtt-client" service account from above
415400
# Otherwise create it with `kubectl create serviceaccount mqtt-client -n azure-iot-operations`
416401
serviceAccountName: mqtt-client
417402
containers:

0 commit comments

Comments
 (0)