Hide last authors
Xiaoling 14.3 1 **Table of Contents:**
Xiaoling 14.2 2
Xiaoling 16.2 3 {{toc/}}
Xiaoling 14.3 4
5
6
Kilight Cao 20.1 7 = 1. Introduction =
Xiaoling 14.3 8
Kilight Cao 20.1 9 Azure IoT Hub is designed around standalone end devices communicating directly with the hub. Each end device must connect to the hub via one of the supported communication protocols ([[MQTT>>url:https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support]] / [[AMQP>>url:https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-amqp-support]]). These protocols are inherently stateful - each individual end device must have one connection always open in order to send and receive messages from the Azure IoT Hub.
Xiaoling 16.2 10
Kilight Cao 20.1 11 The Azure IoT Hub integration prefers to use an asynchronous, stateless communication style. When uplink messages are received from an end device, the integration connects on demand to the Azure IoT Hub and submits the message, and also updates the Device Twin. The data plane protocol used between The Things Stack and Azure IoT Hub is [[MQTT>>url:https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-mqtt-support]], and the connections are always secure using [[TLS 1.2>>url:https://datatracker.ietf.org/doc/html/rfc5246]].
Xiaoling 14.3 12
Kilight Cao 20.1 13 (% class="wikigeneratedid" %)
14 [[image:image-20230511145209-1.png||height="600" width="813"]]
Xiaoling 14.3 15
Kilight Cao 20.1 16
17 = 2. Deployment Guide =
18
19
Xiaoling 14.2 20 Learn how to deploy the Azure IoT Hub integration for The Things Stack.
21
22
Xiaoling 14.3 23
Kilight Cao 20.1 24 == 2.1 Prerequisites ==
Xiaoling 14.3 25
Kilight Cao 20.1 26
Xiaoling 16.2 27 1.  Access to an Azure account. [[Create a new account>>url:https://signup.azure.com/]]
Xiaoling 14.3 28
Xiaoling 16.2 29 2. An application in The Things Stack. [[See instructions>>url:https://www.thethingsindustries.com/docs/integrations/adding-applications/]]
Xiaoling 14.2 30
Xiaoling 16.2 31
Kilight Cao 20.1 32 == 2.2 Create API Key ==
Xiaoling 14.2 33
34
Xiaoling 14.3 35 Go to your application in The Things Stack Console, navigate to (% style="color:blue" %)**Integrations → Azure IoT**(%%) on the left hand menu and click on (% style="color:blue" %)**Expand** (%%)next to (% style="color:blue" %)**Azure IoT Hub**(%%). Now click on (% style="color:blue" %)**Generate API Key**.
36
37
Xiaoling 14.2 38 [[image:image-20230105112836-1.png]]
39
Xiaoling 14.3 40
Xiaoling 14.2 41 Copy the generated API key and store it in a safe place, because you will need it in the next section.
42
Xiaoling 14.3 43 Leave the integration page open, as you will need to copy in your (% style="color:blue" %)**Azure IoT Hub hostname** (%%)and (% style="color:blue" %)**Azure IoT Hub access key**(%%) before saving the integration.
Xiaoling 14.2 44
45
Kilight Cao 20.1 46 == 2.3 Deploy Azure Resource Manager Template ==
Xiaoling 14.3 47
48
Xiaoling 14.2 49 [[Deploy template>>url:https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fttsiothubintegration.blob.core.windows.net%2Fintegration-releases%2Flatest%2Fmain.json]]
50
51 View template as [[JSON>>url:https://ttsiothubintegration.blob.core.windows.net/integration-releases/latest/main.json]] or [[Bicep>>url:https://ttsiothubintegration.blob.core.windows.net/integration-releases/latest/main.bicep]]
52
53
Kilight Cao 20.1 54 == 2.4 Settings ==
Xiaoling 14.3 55
56
Xiaoling 14.2 57 The following parameters configure the integration:
58
Xiaoling 14.3 59 * (% style="color:#037691" %)**Location**(%%): The region in which the Azure resources will be deployed. Defaults to the region used by the selected Resource Group.
Xiaoling 14.2 60
Xiaoling 14.3 61 * (% style="color:#037691" %)**Name Suffix**(%%): The suffix added to the Azure Resources. Defaults to a random string.
62
63 * (% style="color:#037691" %)**Stack Cluster Address**(%%): The address of your The Things Stack deployment. Can be retrieved from the (% style="color:blue" %)**Azure IoT**(%%) integration page in The Things Stack (see image above).
64
65 * (% style="color:#037691" %)**Stack Application ID**(%%): The application ID of your application. Can be retrieved from the (% style="color:blue" %)**Azure IoT** (%%)integration page in The Things Stack (see image above).
66
67 * (% style="color:#037691" %)**Stack API Key**(%%): The application API key that you generated in the previous step.
68
69 * (% style="color:#037691" %)**Enable fallback route**(%%): Defines if the Azure IoT Hub fallback route should be added. If enabled, uplink messages will be submitted to the default endpoint in your Azure IoT Hub.events
70
Xiaoling 14.2 71 [[image:image-20230105112836-2.png]]
72
Xiaoling 16.2 73 Click (% style="color:blue" %)**Review + Create**(%%), then (% style="color:blue" %)**Create**.
Xiaoling 14.2 74
75
Xiaoling 14.3 76 (% style="color:red" %)**Note:**
77
Xiaoling 14.2 78 Creating all resources can take up to five minutes. ☕
79
Xiaoling 16.2 80 When the deployment is done, you’ll see the status .Your deployment is complete.
Xiaoling 14.2 81
Xiaoling 16.2 82
Xiaoling 14.2 83 [[image:image-20230105112836-3.png]]
84
85
Xiaoling 14.3 86 After the deployment has finished, click (% style="color:blue" %)**Outputs**.
87
Xiaoling 16.2 88 [[image:image-20230105135055-2.png]]
Xiaoling 14.2 89
90
Xiaoling 16.2 91 The two outputs can now be copied into your integration settings as (% style="color:blue" %)**Azure IoT Hub hostname**(%%) and (% style="color:blue" %)**Azure IoT Hub access key**(%%). Click on (% style="color:blue" %)**Enable/Update Azure IoT Hub integration**.
92
Xiaoling 14.2 93 [[image:image-20230105112836-5.png]]
94
95
Kilight Cao 20.1 96 = 3. Managing Devices =
Xiaoling 14.3 97
98
Xiaoling 14.2 99 The Azure IoT Hub integration for The Things Stack synchronizes the device registry: you can create devices in Azure IoT Hub which trigger an Azure Function that creates the device in The Things Stack.
100
101
Xiaoling 14.3 102 (% style="color:red" %)**Note:**
103
Xiaoling 14.2 104 Devices that you create in The Things Stack are automatically created as Azure IoT Hub devices as soon as they activate or send their first uplink message.
105
106 In Azure IoT Hub, create only devices that are not yet in your The Things Stack application.
107
108
Xiaoling 14.3 109 (% style="color:blue" %)**Device Names:**
110
Xiaoling 14.2 111 Devices are created automatically as they join the network or send an uplink message. For the name of new devices, the end device ID in The Things Stack is used as the device ID in Azure IoT Hub.
112
113
Kilight Cao 20.1 114 == 3.1 Creating Devices ==
Xiaoling 14.3 115
Xiaoling 16.2 116
Xiaoling 14.2 117 You can use Azure IoT Hub to create and claim devices in The Things Stack. This is useful to manage all your devices in one place, without having to use The Things Stack Console, CLI or API.
118
Xiaoling 14.3 119 (% style="color:blue" %)**Creating**(%%) a device allows you to add any LoRaWAN device by manually entering its information and security keys.
Xiaoling 14.2 120
Xiaoling 14.3 121 In the Azure Console, open your Azure IoT Hub resource. In the menu on the left, click (% style="color:blue" %)**IoT Devices**.
Xiaoling 14.2 122
Xiaoling 14.3 123 Click (% style="color:blue" %)**Add Device**.
Xiaoling 14.2 124
125 [[image:image-20230105112836-6.png]]
126
Xiaoling 16.2 127
Xiaoling 14.3 128 As (% style="color:blue" %)**Device ID**(%%), enter any device ID you like. Hit (% style="color:blue" %)**Save**.
Xiaoling 14.2 129
Xiaoling 16.2 130
Xiaoling 14.3 131 (% style="color:red" %)**Note:**
Xiaoling 14.2 132
133 See [[ID and EUI constraints>>url:https://www.thethingsindustries.com/docs/reference/id-eui-constraints/]] for guidelines about choosing a unique ID.
134
135 [[image:image-20230105112836-7.png]]
136
Xiaoling 16.2 137
Xiaoling 14.3 138 You will now have to setup the LoRaWAN specific settings of the device. Click on (% style="color:blue" %)**Device Twin**.
Xiaoling 14.2 139
Xiaoling 16.2 140 [[image:image-20230105134348-1.png]]
Xiaoling 14.2 141
Xiaoling 16.2 142
Xiaoling 14.2 143 You will now be presented with a JSON document containing the Device Twin. You now have to add a new object called tags, which will contain an object called lorawan with the LoRaWAN specific tags. You will have to specify the following tags:
144
Xiaoling 16.2 145 * (% style="color:#037691" %)**devEui:**(%%) the hexadecimal LoRaWAN DevEUI.
Xiaoling 14.2 146
Xiaoling 16.2 147 * (% style="color:#037691" %)**joinEui:**(%%)** **the hexadecimal LoRaWAN JoinEUI (or AppEUI).
Xiaoling 14.3 148
Xiaoling 16.2 149 * (% style="color:#037691" %)**lorawanVersion:**(%%) either 1.0, 1.0.1, 1.0.2, 1.0.3 or 1.1.
Xiaoling 14.3 150
Xiaoling 16.2 151 * (% style="color:#037691" %)**regionalParametersVersion:**(%%) either 1.0, 1.0.1, 1.0.2 (or 1.0.2-a), 1.0.2-b, 1.0.3-a, 1.1-a or 1.1-b.
Xiaoling 14.3 152
Xiaoling 16.2 153 * (% style="color:#037691" %)**appKey:**(%%) the hexadecimal LoRaWAN AppKey.
Xiaoling 14.3 154
Xiaoling 16.2 155 * (% style="color:#037691" %)**nwkKey:**(%%) the hexadecimal LoRaWAN NwkKey (only when using LoRaWAN 1.1 or higher).
Xiaoling 14.3 156
Xiaoling 16.2 157 * (% style="color:#037691" %)**frequencyPlanId:**(%%) the frequency plan ID. See [[Frequency Plans>>url:https://www.thethingsindustries.com/docs/reference/frequency-plans/]] for the supported values.
Xiaoling 14.3 158
Xiaoling 14.2 159 If your end device is a part of the [[LoRaWAN Device Repository>>url:https://www.thethingsindustries.com/docs/integrations/payload-formatters/device-repo/]], you may provide the identifiers of the device as part of an optional versionIdentifiers object. You can specify the following information as part of the identifiers:
160
Xiaoling 16.2 161 * (% style="color:#037691" %)**bandId:**(%%) the band ID.
Xiaoling 14.2 162
Xiaoling 16.2 163 * (% style="color:#037691" %)**brandId:**(%%) the brand ID.
Xiaoling 14.2 164
Xiaoling 16.2 165 * (% style="color:#037691" %)**firmwareVersion:**(%%) the firmware version.
Xiaoling 14.3 166
Xiaoling 16.2 167 * (% style="color:#037691" %)**hardwareVersion:**(%%) the hardware version.
Xiaoling 14.3 168
Xiaoling 16.2 169 * (% style="color:#037691" %)**modelId:**(%%) the model ID.
Xiaoling 14.3 170
171 (% style="color:red" %)**Note:**
172
Xiaoling 14.2 173 If the version identifiers are provided, the end device will automatically load the [[Payload Formatters>>url:https://www.thethingsindustries.com/docs/integrations/payload-formatters/]] from [[LoRaWAN Device Repository>>url:https://www.thethingsindustries.com/docs/integrations/payload-formatters/device-repo/]].
174
175 The final JSON tags object should look as follows:
176
177 {
178
179 "lorawan":{
180
181 "devEui":"0004A30B001C5838",
182
183 "joinEui":"800000000000000C",
184
185 "lorawanVersion":"1.0.2",
186
187 "regionalParametersVersion":"1.0.2-b",
188
189 "frequencyPlanId":"EU_863_870_TTN",
190
191 "appKey":"459B77D46A08C427254822A33F6FA1A3",
192
193 "versionIdentifiers":{
194
195 "bandId":"EU_863_870",
196
197 "brandId":"the-things-products",
198
199 "firmwareVersion":"1.0",
200
201 "hardwareVersion":"1.0",
202
203 "modelId":"the-things-node"
204
205 }
206
207 }
208
209 }
210
Xiaoling 16.2 211
Xiaoling 14.2 212 [[image:image-20230105112836-9.png]]
213
Xiaoling 14.3 214 Click on (% style="color:blue" %)**Save**(%%) in the top-left corner. The end device will now be created in The Things Stack.
Xiaoling 14.2 215
216
Kilight Cao 20.1 217 == 3.2 Deleting Devices ==
Xiaoling 16.2 218
219
Xiaoling 14.3 220 In the Azure Console, open your Azure IoT Hub resource. In the menu on the left, click (% style="color:blue" %)**IoT Devices**.
Xiaoling 14.2 221
Xiaoling 14.3 222 Click on the checkbox in front of the device you want to delete, then click (% style="color:blue" %)**Delete**.
Xiaoling 14.2 223
224 [[image:image-20230105112836-10.png]]
225
226 The end device will be deleted from Azure IoT Hub and The Things Stack.
227
228
Xiaoling 16.2 229 (% style="color:blue" %)**Example(TrackerD):**
230
Xiaoling 14.2 231 [[image:image-20230105112836-11.png]]
232
Xiaoling 16.2 233
Xiaoling 14.2 234 [[image:image-20230105112836-12.png]]
235
236
Xiaoling 16.2 237 (% style="color:blue" %)**Example(LHT65N):**
Xiaoling 14.2 238
Xiaoling 18.2 239 [[image:image-20230105135558-2.png||height="495" width="1360"]]
Xiaoling 14.2 240
Xiaoling 16.2 241
Xiaoling 14.2 242 [[image:image-20230105112836-14.png]]
Copyright ©2010-2022 Dragino Technology Co., LTD. All rights reserved
Dragino Wiki v2.0