Azure IoT 中模块孪生的安全问题

问题描述 投票:0回答:1

我的上下文涉及 IoT 中心和 IoT 边缘设备以及 Azure IoT 中的自定义 IoT 边缘模块。

我知道每个边缘模块都可以将属性存储在云端的 IoT HUB 中,称为模块孪生(JSON 文档),而且我也知道模块孪生的目的是通过使用加密的连接来处理和传播更改到边缘侧物联网中心。

关于 Module Twin 的安全性,我想知道两件事:

  • Edge 侧的 module twin 存储在哪里?
  • 模块孪生在边缘侧加密吗?

谢谢

azure azure-iot-hub azure-iot-edge
1个回答
0
投票

通过使用此参考MSDOCMSDOC2

c# code
我可以在模块身份孪生中看到Azure IoT的模块孪生。

AFAIK,模块孪生以 JSON 文档的形式存储在边缘设备上。

代码:-

 var connectionString = "HostName=sampath23sa454.azure-devices.net;SharedAc";
 var registryManager = RegistryManager.CreateFromConnectionString(connectionString);

 var edgeDeviceId = "sampathp"; // Replace with the ID of your edge device
 var moduleId = "OPCPublisher"; // Replace with the ID of your module

 var query = registryManager.CreateQuery($"SELECT * FROM devices.modules WHERE deviceId = '{edgeDeviceId}' AND moduleId = '{moduleId}'", 1);
 while (query.HasMoreResults)
 {
     var page = await query.GetNextAsTwinAsync();
     foreach (var twin in page)
     {
         // Update twin properties and tags
         twin.Properties.Desired["sampleProperty"] = "newValue";

         twin.Tags = new TwinCollection();
         twin.Tags["location"] = "Building A";
         twin.Tags["temperature"] = "72F";

         // Update twin in the registry
         try
         {
             var updatedTwin = await registryManager.UpdateTwinAsync(twin.DeviceId, twin.ModuleId, twin, twin.ETag);
             Console.WriteLine("Twin updated successfully!");
             Console.WriteLine($"Device ID: {updatedTwin.DeviceId}");
             Console.WriteLine($"Module ID: {updatedTwin.ModuleId}");
             Console.WriteLine($"Desired properties: {updatedTwin.Properties.Desired.ToJson()}");
             Console.WriteLine($"Reported properties: {updatedTwin.Properties.Reported.ToJson()}");
             Console.WriteLine($"Tags: {updatedTwin.Tags.ToJson()}");
         }
         catch (Exception ex)
         {
             Console.WriteLine($"Error updating twin: {ex.Message}");
         }
     }
 }




输出:-

enter image description here

enter image description here

其他参考资料:-

© www.soinside.com 2019 - 2024. All rights reserved.