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
Data can also be routed to different services for further processing. As the IoT solution scales out, the number of devices, volume of events, variety of events, and different services also varies. A flexible, scalable, consistent, and reliable method to route events is necessary to serve this pattern. Once a message route has been created, data stops flowing to the built-in-endpoint unless a fallback route has been configured. For a tutorial showing multiple uses of message routing, see the [Routing Tutorial](tutorial-routing.md).
112
112
113
+
IoT Hub supports setting up custom endpoints for various existing Azure services like Storage containers, Event Hubs, Service Bus queues, Service Bus topics, and Cosmos DB. Once the endpoint has been set up, you can route your IoT data to any of these endpoints to perform downstream data operations.
114
+
113
115
IoT Hub also integrates with Event Grid, which enables you to fan out data to multiple subscribers. Event Grid is a fully managed event service that enables you to easily manage events across many different Azure services and applications. Made for performance and scale, it simplifies building event-driven applications and serverless architectures. The differences between message routing and using Event Grid are explained in the [Message Routing and Event Grid Comparison](iot-hub-event-grid-routing-comparison.md)
114
116
115
117
## Next steps
@@ -124,3 +126,4 @@ To learn more about the ways you can build and deploy IoT solutions with Azure I
124
126
125
127
-[What is Azure IoT device and application development](../iot-develop/about-iot-develop.md)
126
128
-[Fundamentals: Azure IoT technologies and solutions](../iot-fundamentals/iot-services-and-technologies.md)
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-devguide-messages-d2c.md
+26-5Lines changed: 26 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,10 +36,11 @@ If your custom endpoint has firewall configurations, consider using the [Microso
36
36
IoT Hub currently supports the following endpoints:
37
37
38
38
- Built-in endpoint
39
-
-Azure Storage
39
+
- Storage containers
40
40
- Service Bus Queues and Service Bus Topics
41
-
- Event Hubs
42
-
41
+
- Event Hubs
42
+
- Cosmos DB (preview)
43
+
43
44
## Built-in endpoint as a routing endpoint
44
45
45
46
You can use standard [Event Hubs integration and SDKs](iot-hub-devguide-messages-read-builtin.md) to receive device-to-cloud messages from the built-in endpoint (**messages/events**). Once a Route is created, data stops flowing to the built-in-endpoint unless a Route is created to that endpoint. Even if no routes are created, a fallback route must be enabled to route messages to the built-in endpoint. The fallback is enabled by default if you create your hub using the portal or the CLI.
@@ -94,6 +95,26 @@ Service Bus queues and topics used as IoT Hub endpoints must not have **Sessions
94
95
95
96
Apart from the built-in-Event Hubs compatible endpoint, you can also route data to custom endpoints of type Event Hubs.
96
97
98
+
## Azure Cosmos DB as a routing endpoint (preview)
99
+
You can send data directly to Azure Cosmos DB from IoT Hub. Cosmos DB is a fully managed hyperscale multi-model database service. It provides very low latency and high availability, making it a great choice for scenarios like connected solutions and manufacturing which require extensive downstream data analysis.
100
+
101
+
IoT Hub supports writing to Cosmos DB in JSON (if specified in the message content-type) or as Base64 encoded binary. In order to set up a route to Cosmos DB, you will have to do the following:
102
+
103
+
From your provisioned IoT Hub, go to the Hub settings and click on message routing. Go to the Custom endpoints tab, click on Add and select Cosmos DB. The following image shows the endpoint addition:
104
+
105
+

106
+
107
+
Enter your endpoint name. You should be able to choose from a list of Cosmos DB accounts available for selection, along with the Database and collection.
108
+
109
+
As Cosmos DB is a hyperscale datastore, all data/documents written to it must contain a field that represents a logical partition. The partition key property name is defined at the Container level and cannot be changed once it has been set. Each logical partition has a maximum size of 20GB. To effectively support high-scale scenarios, you can enable [Synthetic Partition Keys](/azure/cosmos-db/nosql/synthetic-partition-keys) for the Cosmos DB endpoint and configure them based on your estimated data volume. For example, in manufacturing scenarios, your logical partition might be expected to approach its max limit of 20 GB within a month. In that case, you can define a Synthetic Partition Key which is a combination of the device id and the month. This key will be automatically added to the partition key field for each new Cosmos DB record, ensuring logical partitions are created each month for each device.
110
+
111
+
You can choose any of the supported authentication types for accessing the database, based on your system setup.
112
+
113
+
> [!Caution]
114
+
> If you are using the System managed identity for authenticating to CosmosDB, you will need to have a “Cosmos DB Built in Data Contributor” Role assigned via CLI. The role setup is not supported from the portal today. For more details on the various roles, see [Configure role-based access for Azure Cosmos DB](/azure/cosmos-db/how-to-setup-rbac). To understand assigning roles via CLI, see [Manage Azure Cosmos DB SQL role resources.](/cli/azure/cosmosdb/sql/role)
115
+
116
+
Once you have selected all the details, click on create and complete the setup of the custom endpoint.
117
+
97
118
## Reading data that has been routed
98
119
99
120
You can configure a route by following this [tutorial](tutorial-routing.md).
@@ -110,7 +131,6 @@ Use the following tutorials to learn how to read messages from an endpoint.
110
131
111
132
* Read from [Service Bus Topics](../service-bus-messaging/service-bus-dotnet-how-to-use-topics-subscriptions.md)
112
133
113
-
114
134
## Fallback route
115
135
116
136
The fallback route sends all the messages that don't satisfy query conditions on any of the existing routes to the built-in-Event Hubs (**messages/events**), that is compatible with [Event Hubs](../event-hubs/index.yml). If message routing is turned on, you can enable the fallback route capability. Once a route is created, data stops flowing to the built-in-endpoint, unless a route is created to that endpoint. If there are no routes to the built-in-endpoint and a fallback route is enabled, only messages that don't match any query conditions on routes will be sent to the built-in-endpoint. Also, if all existing routes are deleted, fallback route must be enabled to receive all data at the built-in-endpoint.
@@ -121,7 +141,6 @@ You can enable/disable the fallback route in the Azure portal->Message Routing b
121
141
122
142
In addition to device telemetry, message routing also enables sending device twin change events, device lifecycle events, digital twin change events, and device connection state events. For example, if a route is created with data source set to **device twin change events**, IoT Hub sends messages to the endpoint that contain the change in the device twin. Similarly, if a route is created with data source set to **device lifecycle events**, IoT Hub sends a message indicating whether the device or module was deleted or created. For more information about device lifecycle events, see [Device and module lifecycle notifications](./iot-hub-devguide-identity-registry.md#device-and-module-lifecycle-notifications). When using [Azure IoT Plug and Play](../iot-develop/overview-iot-plug-and-play.md), a developer can create routes with data source set to **digital twin change events** and IoT Hub sends messages whenever a digital twin property is set or changed, a digital twin is replaced, or when a change event happens for the underlying device twin. Finally, if a route is created with data source set to **device connection state events**, IoT Hub sends a message indicating whether the device was connected or disconnected.
123
143
124
-
125
144
[IoT Hub also integrates with Azure Event Grid](iot-hub-event-grid.md) to publish device events to support real-time integrations and automation of workflows based on these events. See key [differences between message routing and Event Grid](iot-hub-event-grid-routing-comparison.md) to learn which works best for your scenario.
126
145
127
146
## Limitations for device connection state events
@@ -155,3 +174,5 @@ Use the [troubleshooting guide for routing](troubleshoot-message-routing.md) for
155
174
*[How to send device-to-cloud messages](../iot-develop/quickstart-send-telemetry-iot-hub.md?pivots=programming-language-nodejs)
156
175
157
176
* For information about the SDKs you can use to send device-to-cloud messages, see [Azure IoT SDKs](iot-hub-devguide-sdks.md).
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-devguide-messages-read-custom.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,18 +40,19 @@ For more information about creating custom endpoints in IoT Hub, see [IoT Hub en
40
40
41
41
For more information about reading from custom endpoints, see:
42
42
43
-
* Reading from [Azure Storage containers](../storage/blobs/storage-blobs-introduction.md).
44
-
43
+
* Reading from [Storage containers](../storage/blobs/storage-blobs-introduction.md).
45
44
* Reading from [Event Hubs](../event-hubs/event-hubs-dotnet-standard-getstarted-send.md).
46
45
47
46
* Reading from [Service Bus queues](../service-bus-messaging/service-bus-dotnet-get-started-with-queues.md).
48
47
49
48
* Reading from [Service Bus topics](../service-bus-messaging/service-bus-dotnet-how-to-use-topics-subscriptions.md).
50
-
49
+
* Reading from [Cosmos DB](/azure/cosmos-db/nosql/query/getting-started)
51
50
## Next steps
52
51
53
52
* For more information about IoT Hub endpoints, see [IoT Hub endpoints](iot-hub-devguide-endpoints.md).
54
53
55
54
* For more information about the query language you use to define routing queries, see [Message Routing query syntax](iot-hub-devguide-routing-query-syntax.md).
56
55
57
56
* The [Process IoT Hub device-to-cloud messages using routes](tutorial-routing.md) tutorial shows you how to use routing queries and custom endpoints.
0 commit comments