Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/411.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在Azure函数中获取设备孪生信息?_Javascript_Azure - Fatal编程技术网

Javascript 在Azure函数中获取设备孪生信息?

Javascript 在Azure函数中获取设备孪生信息?,javascript,azure,Javascript,Azure,所以我有一个azure函数,它从CSV文件中检索数据。我想做的是,在azure函数中检索该信息时,首先检查是否可以获取设备的详细信息。这一切都是在azure函数中的javascript中完成的。因此,该函数是一个异步函数: async function getDeviceTwin(){ var devicetwin= await registryManager.GetTwinAsync(deviceID); context.log("device is "+ devicetw

所以我有一个azure函数,它从CSV文件中检索数据。我想做的是,在azure函数中检索该信息时,首先检查是否可以获取设备的详细信息。这一切都是在azure函数中的javascript中完成的。因此,该函数是一个异步函数:

async function getDeviceTwin(){
var devicetwin= await registryManager.GetTwinAsync(deviceID);
context.log("device is "+ devicetwin.deviceId+ "status is " + deviceTwin.status);
}
这个函数显然是这样调用的:

getDeviceTwin()
设备ID位于此处:

IotHubMessages,forEach(newmessage=>{
console.log('message':${newmessage}');
count++;
deviceID=message.deviceID;

当我在azure函数中运行它时,似乎什么也找不到。为什么会出现这种情况

您应该更改代码
devicetwin.deviceId
devicetwin.status

比如:

关于更多细节,你可以在这篇文章中参考我的答案


你的分数表让我震惊。如果你按时接受答案,人们会更乐意帮助你:)如果我的解决方案对你有帮助,你能把我的答案标记为,tks吗~
console.log("device is "+ devicetwin.responseBody.deviceId+ "status is " + devicetwin.responseBody.status);