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/connect-to-cloud/tutorial-connect-event-grid.md
+50-7Lines changed: 50 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ ms.subservice: mq
7
7
ms.custom: devx-track-azurecli
8
8
ms.author: patricka
9
9
ms.topic: tutorial
10
-
ms.date: 11/15/2023
10
+
ms.date: 02/28/2024
11
11
12
12
#CustomerIntent: As an operator, I want to configure IoT MQ to bridge to Azure Event Grid MQTT broker PaaS so that I can process my IoT data at the edge and in the cloud.
13
13
---
@@ -22,12 +22,46 @@ In this tutorial, you learn how to configure IoT MQ for bi-directional MQTT brid
Set environment variables for the rest of the setup. Replace values in `<>` with valid values or names of your choice. A new Azure Event Grid namespace and topic space are created in your Azure subscription based on the names you provide:
35
+
36
+
```azurecli
37
+
# For this tutorial, the steps assume the IoT Operations cluster and the Event Grid
38
+
# are in the same subscription, resource group, and location.
39
+
40
+
# Name of the resource group of Azure Event Grid and IoT Operations cluster
41
+
export RESOURCE_GROUP=<RESOURCE_GROUP_NAME>
42
+
43
+
# Azure region of Azure Event Grid and IoT Operations cluster
# Subscription ID of Azure Event Grid and IoT Operations cluster
53
+
export SUBSCRIPTION_ID=<SUBSCRIPTION_ID>
54
+
```
55
+
25
56
## Create Event Grid namespace with MQTT broker enabled
26
57
27
-
[Create Event Grid namespace](../../event-grid/create-view-manage-namespaces.md) with Azure CLI. Replace `<EG_NAME>`, `<RESOURCE_GROUP>`, and `<LOCATION>` with your own values. The location should be the same as the one you used to deploy Azure IoT Operations.
58
+
[Create Event Grid namespace](../../event-grid/create-view-manage-namespaces.md) with Azure CLI. The location should be the same as the one you used to deploy Azure IoT Operations.
By setting the `topic-spaces-configuration`, this command creates a namespace with:
@@ -39,20 +73,29 @@ The max client sessions option allows IoT MQ to spawn multiple instances and sti
39
73
40
74
## Create a topic space
41
75
42
-
In the Event Grid namespace, create a topic space named `tutorial` with a topic template `telemetry/#`. Replace `<EG_NAME>` and `<RESOURCE_GROUP>` with your own values.
76
+
In the Event Grid namespace, create a topic space named `tutorial` with a topic template `telemetry/#`.
az eventgrid namespace topic-space create --resource-group $RESOURCE_GROUP \
80
+
--namespace-name $EVENT_GRID_NAMESPACE \
81
+
--name tutorial \
82
+
--topic-templates "telemetry/#"
46
83
```
47
84
48
85
By using the `#` wildcard in the topic template, you can publish to any topic under the `telemetry` topic space. For example, `telemetry/temperature` or `telemetry/humidity`.
49
86
50
87
## Give IoT MQ access to the Event Grid topic space
51
88
52
-
Using `az k8s-extension show`, find the principal ID for the Azure IoT MQ Arc extension.
89
+
Using `az k8s-extension show`, find the principal ID for the Azure IoT MQ Arc extension. The command stores the principal ID in a variable for later use.
53
90
54
91
```azurecli
55
-
az k8s-extension show --resource-group <RESOURCE_GROUP> --cluster-name <CLUSTER_NAME> --name mq --cluster-type connectedClusters --query identity.principalId -o tsv
92
+
export PRINCIPAL_ID=$(az k8s-extension show --resource-group $RESOURCE_GROUP \
93
+
--cluster-name $CLUSTER_NAME \
94
+
--name mq \
95
+
--cluster-type connectedClusters \
96
+
--query identity.principalId -o tsv)
97
+
98
+
echo $PRINCIPAL_ID
56
99
```
57
100
58
101
Take note of the output value for `identity.principalId`, which is a GUID value with the following format:
0 commit comments