Skip to content

Commit 55307fa

Browse files
authored
Update how-to-routing-azure-cli.md
1 parent d735fbc commit 55307fa

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

articles/iot-hub/how-to-routing-azure-cli.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ References used in the following commands:
282282
1. Create your custom endpoint. Use the connection string in this command that you copied in the last step. The `endpoint-type` must be `eventhub`, otherwise all other values should be your own.
283283

284284
```azurecli
285-
az iot hub message-endpoint cosmosdb-collection create --resource-group my-resource-group --hub-name my-iot-hub --endpoint-name my-cosmosdb-endpoint --endpoint-account my-cosmosdb-account --database-name my-cosmosdb-database --collection my-cosmosdb-database-container --connection-string "copied-connection-string"
285+
az iot hub message-endpoint cosmosdb-collection create --resource-group my-resource-group --hub-name my-iot-hub --endpoint-name my-cosmosdb-endpoint --endpoint-account my-cosmosdb-account --database-name my-cosmosdb-database --container my-cosmosdb-database-container --connection-string "copied-connection-string"
286286
```
287287
> [!NOTE]
288288
> If you are using managed identities instead of connection string, you have to use the following command to authenticate your identity to the CosmosDB account.
@@ -418,7 +418,37 @@ In IoT Hub, you can create a route to send messages or capture events. Each rout
418418
"source": "DeviceConnectionStateEvents"
419419
}
420420
```
421+
# [Cosmos DB](#tab/cosmosdb)
422+
423+
1. With your existing Cosmos DB endpoint, create a new IoT Hub route, using that endpoint. Use the endpoint name for `endpoint`. Use a unique name for `route-name`.
424+
425+
The default fallback route in IoT Hub collects messages from `DeviceMessages`, so let's choose another option for our custom route, such as `DeviceConnectionStateEvents`. For more source options, see [az iot hub route](/cli/azure/iot/hub/route#az-iot-hub-route-create-required-parameters).
426+
427+
```azurecli
428+
az iot hub route create --endpoint my-cosmosdb-endpoint --hub-name my-iot-hub --route-name my-cosmosdb-route --source deviceconnectionstateevents
429+
```
430+
431+
1. A new route should show in your IoT hub. Run this command to confirm the route is there.
432+
433+
```azurecli
434+
az iot hub route list -g my-resource-group --hub-name my-iot-hub
435+
```
436+
437+
You should see a similar response in your console.
421438

439+
```json
440+
[
441+
{
442+
"condition": "true",
443+
"endpointNames": [
444+
"my-cosmosdb-endpoint"
445+
],
446+
"isEnabled": true,
447+
"name": "my-cosmosdb-route",
448+
"source": "DeviceConnectionStateEvents"
449+
}
450+
]
451+
```
422452
---
423453

424454
### Update an IoT Hub route

0 commit comments

Comments
 (0)