After configuring, deploying and then operating my The Things Network(TTN) V2 gateway I have made some changes to my The Things Industries(TTI) V3 gateway.
- Using Azure KeyVault to store configuration was an interesting learning exercise but made configuration difficult for users, so for the initial V3 version(s) I have dropped support and reverted to an app.settings file.
- The V2 gateway used an Azure HTTP Trigger function to process TTN uplink messages which were placed into an Azure Storage Queue for processing by an Azure Queue Trigger function. This was complex to deploy and caused message ordering problems when multiple instances of the storage queue trigger function where spun up to process a backlog of messages.
- The V2 gateway did not process downlink messages and I couldn’t figure out an easy way to configure the mapping of an Azure DeviceClient + applicationId + deviceId to a LoRaWAN device port.
- The V2 Gateway only provisioned devices with the Azure Device Provisioning Service on the first uplink message. This made it difficult to process Downlink messages as there was no Azure DeviceClient connection for devices which hadn’t sent a message. The V3 gateway uses the TTN API to enumerate the devices in each TTN Application configured in the app.settings.json file. For each application a Message Queue Telemetry Transport(MQTT) (using MQTTNet) connection is opened for receiving uplink messages, sending downlink messages and tracking the progress of downlink messages. Then for each TTN Device a connection is establish to the specified Azure IoT Hub to enable Cloud to Device(C2D) and Device to Cloud messaging.
- With so many components the V2 gateway was difficult to debug, so the V3 version runs locally as a console application and in Azure as an Azure continuous Webjob
- After exploring how Azure IoT Central sends synchronous and asynchronous commands and processes telemetry there will have to be Azure IoT Central specific configuration for mapping ReceivedMessages and Methods to LoRaWAN ports.
- The amount of diagnostic logging sent to Azure Application Insights was making it difficult to identify and then diagnose issues so the way logging is implemented has been revisited.

Azure IoT integration can be configured at the Device (TTN Device “azureintegration” attribute).

Then falls back to the Application default (TTN application “azureintegrationdevicedefault” attribute).

Then falls back to the “DeviceIntegrationDefault” setting for the Application then finally “DeviceIntegrationDefault” setting for the webjob the in the app.settings.json file
{
...
"ProgramSettings": {
"Applications": {
"application1": {
"AzureSettings": {
"IoTHubConnectionString": "HostName=TT...n1.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=Am...M=",
"DeviceProvisioningServiceSettings": {
"IdScope": "0n...3B",
"GroupEnrollmentKey": "Kl...Y="
}
},
"MQTTAccessKey": "NNSXS.HC...YQ",
"DeviceIntegrationDefault": false,
"DevicePageSize": 10
},
"seeeduinolorawan": {
"AzureSettings": {
"IoTHubConnectionString": "HostName=TT...n2.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=D2q...L8=",
"DeviceProvisioningServiceSettings": {
"IdScope": "0n...3B",
"GroupEnrollmentKey": "Kl...Y="
}
},
"MQTTAccessKey": "NNSXS.V44...42A",
"DeviceIntegrationDefault": true,
"DevicePageSize": 10
}
},
"AzureSettingsDefault": {
"IoTHubConnectionString": "HostName=TT...ors.azure-devices.net;SharedAccessKeyName=device;SharedAccessKey=yd...k=",
"DeviceProvisioningServiceSettings": {
"IdScope": "0n...3B",
"GroupEnrollmentKey": "Kl...Y="
}
},
"TheThingsIndustries": {
"MqttServerName": "eu1.cloud.thethings.industries",
"MqttClientId": "MQTTClient",
"MqttAutoReconnectDelay": "00:00:05",
"Tenant": "br...st",
"ApiBaseUrl": "https://br..st.eu1.cloud.thethings.industries/api/v3",
"ApiKey": "NNSXS.NR...SA",
"Collaborator": "de...le",
"DevicePageSize": 10,
"DeviceIntegrationDefault": true
}
}
}
This approach is now used for most of the application settings to recue the amount of configuration required for a small scale deployment.
To reduce complexity the initial version of the V3 TTI gateway doesn’t support Azure IoT Central and the Device Provisioning Service(DPS).