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-hub/how-to-routing-azure-cli.md
+77-2Lines changed: 77 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,6 @@ To learn more about how routing works in IoT Hub, see [Use IoT Hub message routi
18
18
## Prerequisites
19
19
20
20
The procedures that are described in the article use the following resources:
21
-
22
21
* The Azure CLI
23
22
* An IoT hub
24
23
* An endpoint service in Azure
@@ -43,6 +42,7 @@ To create an IoT hub route, you need at least one other Azure service to use as
43
42
44
43
Decide which route type you want to create: an event hub, a Service queue or topic, or a storage account. For the service you choose to use, complete the steps to create an endpoint service.
45
44
45
+
46
46
# [Event Hubs](#tab/eventhubs)
47
47
48
48
You can choose an Event Hubs resource (namespace and entity).
@@ -185,6 +185,24 @@ You can choose an Azure Storage resource (account and container).
185
185
186
186
For more information, see [Create a storage account](../storage/common/storage-account-create.md?tabs=azure-cli).
187
187
188
+
# [Cosmos DB](#tab/cosmosdb)
189
+
190
+
You can choose a Cosmos DB endpoint.
191
+
192
+
### Create an Azure Storage resource with container
193
+
194
+
1. Create a new Cosmos DB account for SQL API
195
+
```azurecli
196
+
az group create --name my-resource-group --location "eastus"
197
+
az cosmosdb create --name my-cosmosdb-account --resource-group my-resource-group
For more information, see [Create an Azure Cosmos DB for NoSQL](/cosmos-db/scripts/cli/nosql/create).
205
+
188
206
---
189
207
190
208
## Create an endpoint
@@ -283,6 +301,32 @@ The commands in the following procedures use these references:
283
301
284
302
For more parameter options, see [az iot hub routing-endpoint](/cli/azure/iot/hub/routing-endpoint).
285
303
304
+
# [Cosmos DB](#tab/cosmosdb)
305
+
306
+
References used in the following commands:
307
+
*[az cosmosdb](/cli/azure/cosmosdb)
308
+
*[az iot hub](/cli/azure/iot/hub)
309
+
310
+
### Create a Cosmos DB endpoint
311
+
312
+
1. Find the Cosmos DB connection string and copy for later use.
313
+
314
+
```azurecli
315
+
az cosmosdb keys list --name my-cosmosdb-account --resource-group my-resource-group --type connection-strings
316
+
```
317
+
318
+
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.
> 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.
325
+
To see all routing endpoint options, see [az iot hub routing-endpoint](/cli/azure/iot/hub/routing-endpoint).
326
+
327
+
```azurecli
328
+
az cosmosdb sql role assignment create -a my-cosmosdb-account -g my-resource-group --scope '/' -n 'Cosmos DB Built-in Data Contributor' -p "IoT Hub System Assigned or User Assigned Identity"
329
+
```
286
330
---
287
331
288
332
## Create an IoT Hub route
@@ -410,7 +454,37 @@ In IoT Hub, you can create a route to send messages or capture events. Each rout
410
454
"source": "DeviceConnectionStateEvents"
411
455
}
412
456
```
457
+
# [Cosmos DB](#tab/cosmosdb)
458
+
459
+
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`.
460
+
461
+
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).
In this how-to article, you learned how to create a route and endpoint for Event Hubs, Service Bus queues and topics, and Azure Storage.
454
528
455
-
To learn more about message routing, see [Tutorial: Send device data to Azure Storage by using IoT Hub message routing](./tutorial-routing.md?tabs=cli). In the tutorial, you create a storage route and test it with a device in your IoT hub.
529
+
To learn more about message routing, see [Tutorial: Send device data to Azure Storage by using IoT Hub message routing](./tutorial-routing.md?tabs=cli). In the tutorial, you create a storage route and test it with a device in your IoT hub.
In this article, you learn how to use Azure IoT Tools for Visual Studio Code with various management options on your development machine. [Azure IoT Tools](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools) is a useful Visual Studio Code extension that makes IoT Hub management and IoT application development easier. It comes with management options that you can use to perform various tasks.
16
+
In this article, you learn how to use Azure IoT Tools for Visual Studio Code with various management options on your development machine. [Azure IoT Hub for VS Code](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit) is a useful Visual Studio Code extension that makes IoT Hub management and IoT application development easier. It comes with management options that you can use to perform various tasks.
@@ -35,7 +35,7 @@ Device twins are JSON documents that store device state information (metadata, c
35
35
* An active Azure subscription.
36
36
* An Azure IoT hub under your subscription.
37
37
*[Visual Studio Code](https://code.visualstudio.com/)
38
-
*[Azure IoT Tools for VS Code](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-tools) or copy this URL and paste it into a browser window:`vscode:extension/vsciot-vscode.azure-iot-tools`.
38
+
*[Azure IoT Hub for VS Code](https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.azure-iot-toolkit) or copy this URL and paste it into a browser window:`vscode:extension/vsciot-vscode.azure-iot-toolkit`.
39
39
40
40
## Sign in to access your IoT hub
41
41
@@ -86,6 +86,6 @@ To send a message from your IoT hub to your device, follow these steps:
86
86
87
87
## Next steps
88
88
89
-
You've learned how to use Azure IoT Tools extension for Visual Studio Code with various management options.
89
+
You've learned how to use Azure IoT Hub for Visual Studio Code with various management options.
0 commit comments