Skip to content

Commit 9676af7

Browse files
committed
Update cmds with environment vars
1 parent b9240fe commit 9676af7

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

articles/iot-operations/connect-to-cloud/tutorial-connect-event-grid.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Set environment variables for the rest of the setup. Replace values in `<>` with
3535

3636
```azurecli
3737
# For this tutorial, the steps assume the IoT Operations cluster and the Event Grid
38-
# are in the same subscription, resource group, and location.
38+
# are in the same subscription, resource group, and location.
3939
4040
# Name of the resource group of Azure Event Grid and IoT Operations cluster
4141
export RESOURCE_GROUP=<RESOURCE_GROUP_NAME>
@@ -58,7 +58,8 @@ export SUBSCRIPTION_ID=<SUBSCRIPTION_ID>
5858
[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.
5959

6060
```azurecli
61-
az eventgrid namespace create --namespace-name $EVENT_GRID_NAMESPACE \
61+
az eventgrid namespace create \
62+
--namespace-name $EVENT_GRID_NAMESPACE \
6263
--resource-group $RESOURCE_GROUP \
6364
--location $LOCATION \
6465
--topic-spaces-configuration "{state:Enabled,maximumClientSessionsPerAuthenticationName:3}"
@@ -76,7 +77,8 @@ The max client sessions option allows IoT MQ to spawn multiple instances and sti
7677
In the Event Grid namespace, create a topic space named `tutorial` with a topic template `telemetry/#`.
7778

7879
```azurecli
79-
az eventgrid namespace topic-space create --resource-group $RESOURCE_GROUP \
80+
az eventgrid namespace topic-space create \
81+
--resource-group $RESOURCE_GROUP \
8082
--namespace-name $EVENT_GRID_NAMESPACE \
8183
--name tutorial \
8284
--topic-templates "telemetry/#"
@@ -89,7 +91,8 @@ By using the `#` wildcard in the topic template, you can publish to any topic un
8991
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.
9092

9193
```azurecli
92-
export PRINCIPAL_ID=$(az k8s-extension show --resource-group $RESOURCE_GROUP \
94+
export PRINCIPAL_ID=$(az k8s-extension show \
95+
--resource-group $RESOURCE_GROUP \
9396
--cluster-name $CLUSTER_NAME \
9497
--name mq \
9598
--cluster-type connectedClusters \
@@ -104,29 +107,35 @@ Take note of the output value for `identity.principalId`, which is a GUID value
104107
d84481ae-9181-xxxx-xxxx-xxxxxxxxxxxx
105108
```
106109

107-
Then, use Azure CLI to assign publisher and subscriber roles to IoT MQ for the topic space you created. Replace `<MQ_ID>` with the principal ID you found in the previous step, and replace `<SUBSCRIPTION_ID>`, `<RESOURCE_GROUP>`, `<EG_NAME>` with your values matching the Event Grid namespace you created.
110+
Then, use Azure CLI to assign publisher and subscriber roles to IoT MQ for the topic space you created.
108111

109112
Assigning the publisher role:
110113

111114
```azurecli
112-
az role assignment create --assignee <MQ_ID> --role "EventGrid TopicSpaces Publisher" --scope /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.EventGrid/namespaces/<EG_NAME>/topicSpaces/tutorial
115+
az role assignment create \
116+
--assignee $PRINCIPAL_ID \
117+
--role "EventGrid TopicSpaces Publisher" \
118+
--scope /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.EventGrid/namespaces/$EVENT_GRID_NAMESPACE/topicSpaces/tutorial
113119
```
114120

115121
Assigning the subscriber role:
116122

117123
```azurecli
118-
az role assignment create --assignee <MQ_ID> --role "EventGrid TopicSpaces Subscriber" --scope /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.EventGrid/namespaces/<EG_NAME>/topicSpaces/tutorial
124+
az role assignment create \
125+
--assignee $PRINCIPAL_ID \
126+
--role "EventGrid TopicSpaces Subscriber" \
127+
--scope /subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.EventGrid/namespaces/$EVENT_GRID_NAMESPACE/topicSpaces/tutorial
119128
```
120129

121130
> [!TIP]
122131
> The scope matches the `id` of the topic space you created with `az eventgrid namespace topic-space create` in the previous step, and you can find it in the output of the command.
123132
124133
## Event Grid MQTT broker hostname
125134

126-
Use Azure CLI to get the Event Grid MQTT broker hostname. Replace `<EG_NAME>` and `<RESOURCE_GROUP>` with your own values.
135+
Use Azure CLI to get the Event Grid MQTT broker hostname.
127136

128137
```azurecli
129-
az eventgrid namespace show -g <RESOURCE_GROUP> -n <EG_NAME> --query topicSpacesConfiguration.hostname -o tsv
138+
az eventgrid namespace show --resource-group $RESOURCE_GROUP --namespace-name $EVENT_GRID_NAMESPACE --query topicSpacesConfiguration.hostname -o tsv
130139
```
131140

132141
Take note of the output value for `topicSpacesConfiguration.hostname` that is a hostname value that looks like:

0 commit comments

Comments
 (0)