Hi @Anonymous There are couple of places in the Azure function Apps where the patching of Azure Digital Twins is done to the property.
- Line 50 of
ProcessHubToDTEvents.cs
file. Please find the line of the command that comes default with the App
updateTwinData.AppendReplace("/Temperature", temperature.Value<double>());
- Line 73 of
ProcessDTRoutedData.cs
file. Here is the line of code
if (propertyPath.Equals("/Temperature"))
This if condition is specifically looking for a match on Temperature
property and only then updates the Digital twin property.
Can you confirm if you have updated the function in both places to replace Temperature
with the property you have defined.
Please note that these properties are case sensitive and should be used the same way you have defined in your Model.json file
- Inspect the line 44 of
ProcessHubToDTEvents.cs
file which looks up for the telemetry data pushed from IoTHub and retrieves the property that needs to be patched. The property should be the same as what is defined in line 56 ofAzureIoTHub.cs
file. Please refer the below line of code
var temperature = deviceMessage["body"]["testpropupdate"];
- Line 43 of
ProcessHubToDTEvents.cs
class reads the Digital Twin ID to which the JSON patch updates need to be applied for. If you follow the step Register the simulated device with IoT Hub in the tutorial as it is, it will create a device with IDthermostat67
which is different from the$dtID
of the digital twin. The Azure function in fileProcessHubToDTEvents.cs
looks for the same digital twin ID and tries to apply a patch on line 51. Make sure to create a device with ID same as the$dtId
of the digital twin.
Once you have function App code modified to reflect the correct property, please make sure to publish the functions again to Azure portal using Azure CLI command
az functionapp deployment source config-zip --resource-group <resource-group> --name <name-of-your-function-app> --src "<full-path-to-publish.zip>"
so that you have updated code.
After making the above changes, you can see that the property with custom name gets updated as expected on the Azure Digital Twin. Please refer the below images.
Please let us know if you still face issues with the property updates after making the above changes.
If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.