Device Twin Routes from IoT Hub

Category: azure iot hub


Deepbhan on Wed, 19 Dec 2018 06:50:09


I am routing all the device twin updates from IoT Hub to Cosmos DB Via Service Bus Queues and Azure Functions

Flow : IoT Hub-->IoT Hub Message Routes-->Service Bus Queues-->Triggers Azure Function (.NET Core)-->CosmosDB

The sequence is working fine but IoT Hub is sending only Message Body to Azure Function instead of entire IoT Hub Message (which Includes System Properties, App Properties & Body)

The Body contains the below Twin Json but System Properties and Application properties of the IoT Hub Message which has the Device Id and custom properties of the device is not being sent to Azure Function.

If I just receive this Device Twin Json, I would not know which Device this twin information belong to. 


  "version": 26,

  "properties": {

    "desired": {

      "TemperatureUnits": 2,

      "$metadata": {

        "$lastUpdated": "2018-12-18T10:06:54.3757271Z",

        "$lastUpdatedVersion": 22,

        "TemperatureUnits": {

          "$lastUpdated": "2018-12-18T10:06:54.3757271Z",

          "$lastUpdatedVersion": 22



      "$version": 22




Do I have to do something else ?


António Sérgio Azevedo - MSFT on Wed, 19 Dec 2018 11:55:39

Can you share the code you are using on your Azure Function to extract the message properties and body? Also why do you use Service Bus before Azure Function?

This is a good reading: How to use Azure Functions with IoT Hub message routing