I'm using custom allocation policy to register my device through DPS. Reference code for C# can be found here.
I have ported most of the code for Azure function from C# to NodeJS as below:-
module.exports = async function (context, req) {
const regId = req.body.deviceRuntimeContext.registrationId;
const response = {
status: 200,
message: 'Device registered successfully'
};
if (!regId)
{
response.status = 500
}
const requestCustomPayload = req.body.deviceRuntimeContext.payload;
context.res = {
iotHubHostName: req.body.deviceRuntimeContext.payload.hubName
};
}
Now, the issue I'm facing is updating the initial twin for the device in above code. If you check the above link for c# code it has an class called TwinState and TwinCollection which are used to update the intial twin of the device, but same classes or similar api's I was not able to find in NodeJS.
Does the nodejs Azure IoT sdk provide a way to update the initial twin?