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/event-grid/event-schema-iot-hub.md
+44-8Lines changed: 44 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,9 +27,34 @@ Azure IoT Hub emits the following event types:
27
27
| ---------- | ----------- |
28
28
| Microsoft.Devices.DeviceCreated | Published when a device is registered to an IoT hub. |
29
29
| Microsoft.Devices.DeviceDeleted | Published when a device is deleted from an IoT hub. |
30
+
| Microsoft.Devices.DeviceConnected | Published when a device is connected to an IoT hub. |
31
+
| Microsoft.Devices.DeviceDisconnected | Published when a device is disconnected from an IoT hub. |
30
32
31
33
## Example event
32
34
35
+
The schema for DeviceConnected and DeviceDisconnected events have the same structure. This sample event shows the schema of an event raised when a device is connected to an IoT hub:
36
+
37
+
```json
38
+
[{
39
+
"id": "f6bbf8f4-d365-520d-a878-17bf7238abd8",
40
+
"topic": "/SUBSCRIPTIONS/<subscription ID>/RESOURCEGROUPS/<resource group name>/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/<hub name>",
The schema for DeviceCreated and DeviceDeleted events have the same structure. This sample event shows the schema of an event raised when a device is registered to an IoT hub:
34
59
35
60
```json
@@ -43,6 +68,7 @@ The schema for DeviceCreated and DeviceDeleted events have the same structure. T
43
68
"twin": {
44
69
"deviceId": "LogicAppTestDevice",
45
70
"etag": "AAAAAAAAAAE=",
71
+
"deviceEtag": "null",
46
72
"status": "enabled",
47
73
"statusUpdateTime": "0001-01-01T00:00:00",
48
74
"connectionState": "Disconnected",
@@ -70,11 +96,9 @@ The schema for DeviceCreated and DeviceDeleted events have the same structure. T
@@ -94,17 +118,29 @@ All events contain the same top-level data:
94
118
| dataVersion | string | The schema version of the data object. The publisher defines the schema version. |
95
119
| metadataVersion | string | The schema version of the event metadata. Event Grid defines the schema of the top-level properties. Event Grid provides this value. |
96
120
97
-
The contents of the data object are different for each event publisher. For IoT Hub events, the data object contains the following properties:
121
+
For all IoT Hub events, the data object contains the following properties:
98
122
99
123
| Property | Type | Description |
100
124
| -------- | ---- | ----------- |
101
125
| hubName | string | Name of the IoT Hub where the device was created or deleted. |
102
126
| deviceId | string | The unique identifier of the device. This case-sensitive string can be up to 128 characters long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: `- : . + % _ # * ? ! ( ) , = @ ; $ '`. |
103
-
| operationTimestamp | string | The ISO8601 timestamp of the operation. |
104
-
| opType | string | The event type specified for this operation by the IoT Hub: either `DeviceCreated` or `DeviceDeleted`.
127
+
128
+
The contents of the data object are different for each event publisher. For **Device Connected** and **Device Disconnected** IoT Hub events, the data object contains the following properties:
129
+
130
+
| Property | Type | Description |
131
+
| -------- | ---- | ----------- |
132
+
| moduleId | string | The unique identifier of the module. This field is output only for module devices. This case-sensitive string can be up to 128 characters long, and supports ASCII 7-bit alphanumeric characters plus the following special characters: `- : . + % _ # * ? ! ( ) , = @ ; $ '`. |
133
+
| deviceConnectionStateEventInfo | object | Device connection state event information
134
+
| sequenceNumber | string | A number which helps indicate order of device connected or device disconnected events. Latest event will have a sequence number that is higher than the previous event. This number may change by more than 1, but is strictly increasing. See [how to use sequence number](../iot-hub/iot-hub-how-to-order-connection-state-events.md). |
135
+
136
+
The contents of the data object are different for each event publisher. For **Device Created** and **Device Deleted** IoT Hub events, the data object contains the following properties:
137
+
138
+
| Property | Type | Description |
139
+
| -------- | ---- | ----------- |
105
140
| twin | object | Information about the device twin, which is the cloud represenation of application device metadata. |
106
141
| deviceID | string | The unique identifier of the device twin. |
107
-
| etag | string | A piece of information that describes the content of the device twin. Each etag is guaranteed to be unique per device twin. |
142
+
| etag | string | A validator for ensuring consistency of updates to a device twin. Each etag is guaranteed to be unique per device twin. |
143
+
| deviceEtag| string | A validator for ensuring consistency of updates to a device registry. Each deviceEtag is guaranteed to be unique per device registry. |
108
144
| status | string | Whether the device twin is enabled or disabled. |
109
145
| statusUpdateTime | string | The ISO8601 timestamp of the last device twin status update. |
110
146
| connectionState | string | Whether the device is connected or disconnected. |
Copy file name to clipboardExpand all lines: articles/event-grid/event-sources.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
@@ -70,13 +70,14 @@ For examples of Event Hubs as a handler, see [Event Hubs handler](event-handlers
70
70
71
71
## IoT Hub
72
72
73
-
Subscribe to IoT Hub events to respond to device createdand deleted events.
73
+
Subscribe to IoT Hub events to respond to device created, deleted, connected and disconnected events.
74
74
75
75
|Title |Description |
76
76
|---------|---------|
77
-
|[Tutorial: send email notifications about Azure IoT Hub events using Logic Apps](publish-iot-hub-events-to-logic-apps.md)| A logic app sends a notification email every time a device is added to your IoT hub. |
78
-
|[Overview: react to IoT Hub events by using Event Grid to trigger actions](../iot-hub/iot-hub-event-grid.md)| Overview of integrating Iot Hubs with Event Grid. |
77
+
|[Send email notifications about Azure IoT Hub events using Logic Apps](publish-iot-hub-events-to-logic-apps.md)| A logic app sends a notification email every time a device is added to your IoT Hub. |
78
+
|[React to IoT Hub events by using Event Grid to trigger actions](../iot-hub/iot-hub-event-grid.md)| Overview of integrating IoT Hub with Event Grid. |
79
79
|[Event schema](event-schema-iot-hub.md)| Shows fields in IoT Hub events. |
80
+
|[Order device connected and device disconnected events](../iot-hub/iot-hub-how-to-order-connection-state-events.md)| Shows how to order device connection state events. |
Copy file name to clipboardExpand all lines: articles/event-grid/publish-iot-hub-events-to-logic-apps.md
+67-71Lines changed: 67 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,16 +25,15 @@ This article walks through a sample configuration that uses IoT Hub and Event gr
25
25
26
26
* An email account from any email provider that is supported by Azure Logic Apps, like Office 365 Outlook, Outlook.com, or Gmail. This email account is used to send the event notifications. For a complete list of supported Logic App connectors, see the [Connectors overview](https://docs.microsoft.com/connectors/)
27
27
* An active Azure account. If you don't have one, you can [create a free account](http://azure.microsoft.com/pricing/free-trial/).
28
-
* An Iot hub in Azure. If you haven't created one yet, see [Get started with IoT Hub](../iot-hub/iot-hub-csharp-csharp-getstarted.md) for a walkthrough.
28
+
* An IoT Hub in Azure. If you haven't created one yet, see [Get started with IoT Hub](../iot-hub/iot-hub-csharp-csharp-getstarted.md) for a walkthrough.
29
29
30
30
## Create a logic app
31
31
32
32
First, create a logic app and add an Event grid trigger that monitors the resource group for your virtual machine.
33
33
34
34
### Create a logic app resource
35
35
36
-
37
-
1. In the [Azure portal](https://portal.azure.com), select **New** > **Enterprise Integration** > **Logic App**.
36
+
1. In the [Azure portal](https://portal.azure.com), select **New** > **Integration** > **Logic App**.
5. You may receive a pop-up notification that says, **Remember to include a Content-Type header set to application/json in your request.** You can safely ignore this suggestion, and move on to the next section.
67
+
```json
68
+
[{
69
+
"id": "56afc886-767b-d359-d59e-0da7877166b2",
70
+
"topic": "/SUBSCRIPTIONS/<subscription ID>/RESOURCEGROUPS/<resource group name>/PROVIDERS/MICROSOFT.DEVICES/IOTHUBS/<hub name>",
71
+
"subject": "devices/LogicAppTestDevice",
72
+
"eventType": "Microsoft.Devices.DeviceCreated",
73
+
"eventTime": "2018-01-02T19:17:44.4383997Z",
74
+
"data": {
75
+
"twin": {
76
+
"deviceId": "LogicAppTestDevice",
77
+
"etag": "AAAAAAAAAAE=",
78
+
"deviceEtag": "null",
79
+
"status": "enabled",
80
+
"statusUpdateTime": "0001-01-01T00:00:00",
81
+
"connectionState": "Disconnected",
82
+
"lastActivityTime": "0001-01-01T00:00:00",
83
+
"cloudToDeviceMessageCount": 0,
84
+
"authenticationType": "sas",
85
+
"x509Thumbprint": {
86
+
"primaryThumbprint": null,
87
+
"secondaryThumbprint": null
88
+
},
89
+
"version": 2,
90
+
"properties": {
91
+
"desired": {
92
+
"$metadata": {
93
+
"$lastUpdated": "2018-01-02T19:17:44.4383997Z"
94
+
},
95
+
"$version": 1
96
+
},
97
+
"reported": {
98
+
"$metadata": {
99
+
"$lastUpdated": "2018-01-02T19:17:44.4383997Z"
100
+
},
101
+
"$version": 1
102
+
}
103
+
}
104
+
},
105
+
"hubName": "egtesthub1",
106
+
"deviceId": "LogicAppTestDevice"
107
+
},
108
+
"dataVersion": "1",
109
+
"metadataVersion": "1"
110
+
}]
111
+
```
115
112
113
+
5. You may receive a pop-up notification that says, **Remember to include a Content-Type header set to application/json in your request.** You can safely ignore this suggestion, and move on to the next section.
116
114
117
115
### Create an action
118
116
119
117
Actions are any steps that occur after the trigger starts the logic app workflow. For this tutorial, the action is to send an email notification from your email provider.
120
118
121
-
1. Select **New step** then **Add an action**.
122
-
123
-

124
-
125
-
2. Search for **Email**.
119
+
1. Select **New step**. This will open a window to **Choose an action**.
120
+
2. Search for **Email**.
126
121
3. Based on your email provider, find and select the matching connector. This tutorial uses **Office 365 Outlook**. The steps for other email providers are similar.
@@ -150,7 +145,7 @@ Before you leave the Logic Apps Designer, copy the URL that your logic apps is l
150
145
151
146
3. Save this URL so that you can refer to it in the next section.
152
147
153
-
## Publish an event from IoT Hub
148
+
## Configure subscription for IoT Hub events
154
149
155
150
In this section, you configure your IoT Hub to publish events as they occur.
156
151
@@ -164,21 +159,22 @@ In this section, you configure your IoT Hub to publish events as they occur.
164
159

165
160
166
161
4. Create the event subscription with the following values:
167
-
***Name**: Provide a descriptive name.
168
-
***Subscribe to all event types**: Unselect the checkbox.
169
-
***Event types**: Select **DeviceCreated**.
170
-
***Subscriber type**: Select **Web Hook**.
171
-
***Subscriber endpoint**: Paste the URL that you copied from your logic app.
162
+
***Event Type**: Uncheck Subscribe to all event types and select **Device Created** from the menu.
163
+
***Endpoint Details**: Select Endpoint Type as **Web Hook** and click on select endpoint and paste the URL that you copied from your logic app and confirm selection.
You could save the event subscription here, and receive notifications for every device that is created in your IoT hub. For this tutorial, though, let's use the optional fields to filter for specific devices:
167
+
***Event Subscription Details**: Provide a descriptive name and select **Event Grid Schema**
174
168
175
-
***Prefix filter**: Enter `devices/Building1_` to filter for device events in building 1.
176
-
***Suffix filter**: Enter `_Temperature` to filter for device events related to temperature.
169
+
You could save the event subscription here, and receive notifications for every device that is created in your IoT hub. For this tutorial, though, let's use the optional fields to filter for specific devices:
177
170
178
-
When you're done, the form should look like the following example:
171
+
***Subject Begins With**: Enter `devices/Building1_` to filter for device events in building 1.
172
+
***Subject Ends With**: Enter `_Temperature` to filter for device events related to temperature.
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-devguide-identity-registry.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,7 +83,6 @@ The device data that a given IoT solution stores depends on the specific require
83
83
The IoT Hub identity registry contains a field called **connectionState**. Only use the **connectionState** field during development and debugging. IoT solutions should not query the field at run time. For example, do not query the **connectionState** field to check if a device is connected before you send a cloud-to-device message or an SMS.
84
84
85
85
If your IoT solution needs to know if a device is connected, you should implement the *heartbeat pattern*.
86
-
87
86
In the heartbeat pattern, the device sends device-to-cloud messages at least once every fixed amount of time (for example, at least once every hour). Therefore, even if a device does not have any data to send, it still sends an empty device-to-cloud message (usually with a property that identifies it as a heartbeat). On the service side, the solution maintains a map with the last heartbeat received for each device. If the solution does not receive a heartbeat message within the expected time from the device, it assumes that there is a problem with the device.
88
87
89
88
A more complex implementation could include the information from [operations monitoring][lnk-devguide-opmon] to identify devices that are trying to connect or communicate but failing. When you implement the heartbeat pattern, make sure to check [IoT Hub Quotas and Throttles][lnk-quotas].
0 commit comments