如何为 100 多个边缘设备配置单独的模块

How to configure individual modules for 100+ edge devices

我有 100 多台具有多个模块的边缘设备,由自动部署管理。每个设备都有自己的特性,例如最大允许值。我们还有一个外部模块,它需要每个设备唯一的帐户凭据 (id/password/certificate/key)。

我试过了:

我怎样才能完成这个? IoT Edge 对此有推荐的方法/支持/解决方法吗?还是我们应该建立自己的东西?

启用外部模块并设置 属性 默认值的分层部署示例:

"content": {
    "modulesContent": {
        "$edgeAgent": {
            "properties.desired.modules.externalModule1": {
                "settings": {
                    "image": "123.azurecr.io/externalModule1:0.1.12",
                    "createOptions": "{\"NetworkingConfig\":{\"EndpointsConfig\":{\"host\":{}}},\"HostConfig\":{\"NetworkMode\":\"host\",\"LogConfig\":{\"Type\":\"json-file\",\"Config\":{\"max-size\":\"10m\",\"max-file\":\"3\"}}}}"
                },
                "type": "docker",
                "status": "running",
                "restartPolicy": "always",
                "version": "1.0"
            }
        },
        "externalModule1": {
            "properties.desired": {
                "MaxChargePower": 5000,
                "MaxDischargePower": 10000
            }
        }
    }
  }
}

设置设备特定值的分层部署示例:

{
  "content": {
    "modulesContent": {
        "$edgeAgent": {},
        "externalModule1": {       
          "properties.desired.MaxChargePower": 6000,
          "properties.desired.MaxDischargePower": 15000,
          "properties.desired.iotpool_account": {
            "iotpool_id" : "<insert iotpool id>",
            "iotpool_password" : "<insert iotpool password>",
            "cert" : "<insert cert>",
            "key" : "<insert key>"
          }
        }
    }
  }
}

您可以直接修改每个设备的模块孪生,而无需针对设备的自动部署覆盖它。

关键是在自动部署(基本或分层)中引用所需属性的特定部分。在你的例子中 -

"content": {
    "modulesContent": {
        "$edgeAgent": {
            "properties.desired.modules.externalModule1": {
                "settings": {
                    "image": "123.azurecr.io/externalModule1:0.1.12",
                    "createOptions": "{\"NetworkingConfig\":{\"EndpointsConfig\":{\"host\":{}}},\"HostConfig\":{\"NetworkMode\":\"host\",\"LogConfig\":{\"Type\":\"json-file\",\"Config\":{\"max-size\":\"10m\",\"max-file\":\"3\"}}}}"
                },
                "type": "docker",
                "status": "running",
                "restartPolicy": "always",
                "version": "1.0"
            }
        },
        "externalModule1": {
            "properties.desired": {
                "MaxChargePower": 5000,
                "MaxDischargePower": 10000
            }
        }
    }
  }
}

更改为..

"content": {
    "modulesContent": {
        "$edgeAgent": {
            "properties.desired.modules.externalModule1": {
                "settings": {
                    "image": "123.azurecr.io/externalModule1:0.1.12",
                    "createOptions": "{\"NetworkingConfig\":{\"EndpointsConfig\":{\"host\":{}}},\"HostConfig\":{\"NetworkMode\":\"host\",\"LogConfig\":{\"Type\":\"json-file\",\"Config\":{\"max-size\":\"10m\",\"max-file\":\"3\"}}}}"
                },
                "type": "docker",
                "status": "running",
                "restartPolicy": "always",
                "version": "1.0"
            }
        },
        "externalModule1.properties.desired.powerSettings": {
                "MaxChargePower": 5000,
                "MaxDischargePower": 10000
            }
        }
    }
  }
}

现在您可以使用模块孪生来专门化每个设备,而不会覆盖它。您不需要使用嵌套部署,因此您不会 运行 进入部署数量限制:

          "properties.desired.iotpool_account": {
            "iotpool_id" : "<insert iotpool id>",
            "iotpool_password" : "<insert iotpool password>",
            "cert" : "<insert cert>",
            "key" : "<insert key>"
          }