英文:
Azure IoT module twin update gets reverted back
问题
在我的分层部署(单模块)属性中,读取如下:
"properties": {
"desired": {
"PublishInterval": 2000,
"OtherProperty": 1,
"layeredProperties": {}
}
},
...
在应用部署后,我想通过Azure门户在某些设备上添加自定义属性,结果可能如下:
"properties": {
"desired": {
"PublishInterval": 2000,
"OtherProperty": 1,
"layeredProperties": {
"instance-specific-property": 4000
}
}
},
...
几分钟后,此属性被还原,最终得到一个空的 layeredProperties
集合。
在类似的问题上跟进这里和这里,我开始觉得根本无法做到这一点,如果需要在设备上添加一些特定的属性,应该为此创建一个分层部署。
真的没有办法通过部署来更新模块的 twin desired 属性吗?似乎有点杀鸡用牛刀。
英文:
My layered deployment (single module) properties read as follows:
"properties": {
"desired": {
"PublishInterval": 2000,
"OtherProperty": 1
"layeredProperties": {}
}
},
...
After the deployment is applied I would like to add a custom property on some of the devices using the Azure portal, so the result might look like so:
"properties": {
"desired": {
"PublishInterval": 2000,
"OtherProperty": 1
"layeredProperties": {
"instance-specific-property": 4000
}
}
},
...
A few minutes later this property gets reverted back and we end up with an empty layeredProperties
collection.
Following up on similar questions asked here and here Im starting to think that it is not possible to do this at all and if one needs some specific properties on devices there should be a layered deployment created for that.
Is there really no way of updating a module's twin desired properties but using a deployment? Seems like an overkill.
答案1
得分: 0
所以关键是在分层部署中指定所需的属性,以定位特定属性对象,例如:
"properties.desired.powerSettings": {
"MaxChargePower": 5000,
"MaxDischargePower": 10000
}
这是“不可更改”的对象,将由分层部署恢复为原始状态。但现在允许通过 Azure 门户向根对象("properties.desired")添加附加设置,可能如下所示:
"properties": {
"desired": {
"powerSettings": {
"MaxChargePower": 5000,
"MaxDischargePower": 10000
},
"instance-specific-property": 4000,// 新属性,不会被分层部署恢复/移除
....
}
经过测试和验证 - 运行如预期。
英文:
So the trick is to specify the desired properties in a layered deployment that target specific property object e.g.
"properties.desired.powerSettings": {
"MaxChargePower": 5000,
"MaxDischargePower": 10000
}
This is the "unchangeable" object and will get reverted back by the layered deployment. But this now allows adding additional settings to the root object (properties.desired
) through e.g. Azure portal, and it would look something like this
"properties": {
"desired": {
"powerSettings": {
"MaxChargePower": 5000,
"MaxDischargePower": 10000
},
"instance-specific-property": 4000, // new property that won't get reverted/removed by the layered deployment
....
}
Tested and verified - works as expected.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论