Azure IoT 中心 - 无法创建分层部署
Azure IoT Hub - fail to create a layered deploy
我正在尝试为 Azure IoT 中心创建分层部署。
基本完全部署正常。这里的配置:
{
"content": {
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"schemaVersion": "1.0",
"runtime": {
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": "",
"registryCredentials": {
"docker": {
"username": "$CONTAINER_REGISTRY_USERNAME_docker",
"password": "$CONTAINER_REGISTRY_PASSWORD_docker",
"address": "docker.io"
}
}
}
},
"systemModules": {
"edgeAgent": {
"type": "docker",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:1.0",
"createOptions": "{}"
}
},
"edgeHub": {
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.0",
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}"
}
}
},
"modules": {
"Sender": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULEDIR<../Sender>}",
"createOptions": "{}"
}
},
"Module1": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULEDIR<../Module1>}",
"createOptions": "{}"
}
},
"Module2": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULEDIR<../Module2>}",
"createOptions": "{}"
}
},
"Module11": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULEDIR<../Module11>}",
"createOptions": "{}"
}
}
}
}
},
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.0",
"routes": {
"SenderToModule1": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'Module1' INTO BrokeredEndpoint(\"/modules/Module1/inputs/input\")",
"SenderToModule2": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'Module2' INTO BrokeredEndpoint(\"/modules/Module2/inputs/input\")",
"SenderToModule11": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'Module11' INTO BrokeredEndpoint(\"/modules/Module11/inputs/input\")",
"Module1ToModule11": "FROM /messages/modules/Module1/outputs/* INTO BrokeredEndpoint(\"/modules/Module11/inputs/input\")",
"SenderToHub": "FROM /messages/modules/Module1/outputs/* WHERE $body.Receiver = 'Hub' INTO $upstream"
},
"storeAndForwardConfiguration": {
"timeToLiveSecs": 7200
}
}
}
}
}
}
接下来,我尝试创建分层部署启动命令
az iot edge deployment create --layered --deployment-id deploy001 --hub-name <hubname> --content ./layeredtarget.json --target-condition "tags.deviceId='TargetDevice'" --priority 2
此处,layeredtarget.json 文件:
{
"content": {
"modulesContent": {
"$edgeHub": {
"properties.desired.routes.SenderToModule1": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'UPDATE_LAYERED' INTO BrokeredEndpoint(\"/modules/Module1/inputs/input\")"
}
}
}
}
通过启动 powershell 命令,我收到了这个错误:
{'Message': 'ErrorCode:InvalidConfigurationContent;The content provided for configuration is invalid. >Please check and try again', 'ExceptionMessage': 'Tracking ID:f716a3c452914ea4a1ad1ee958a7b2ff-G:5->TimeStamp:01/20/2021 16:14:15'}
我不明白我是否做错了。我关注了这个 Doc
有人知道吗?
如果您还包括 $edgeAgent
,您的分层部署将工作得很好。我所做的就是在门户中重新创建您的部署,检查 JSON 并注意到空的 edgeAgent。我想没有多少人只用一条路线来创建分层部署。不错的主意。我使用 CLI 在我的集线器上测试了下面的 JSON 并且它有效:
{
"content": {
"modulesContent": {
"$edgeAgent": {},
"$edgeHub": {
"properties.desired.routes.SenderToModule1": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'UPDATE_LAYERED' INTO BrokeredEndpoint(\"/modules/Module1/inputs/input\")"
}
}
}
}
我正在尝试为 Azure IoT 中心创建分层部署。
基本完全部署正常。这里的配置:
{
"content": {
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"schemaVersion": "1.0",
"runtime": {
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": "",
"registryCredentials": {
"docker": {
"username": "$CONTAINER_REGISTRY_USERNAME_docker",
"password": "$CONTAINER_REGISTRY_PASSWORD_docker",
"address": "docker.io"
}
}
}
},
"systemModules": {
"edgeAgent": {
"type": "docker",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:1.0",
"createOptions": "{}"
}
},
"edgeHub": {
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.0",
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}],\"443/tcp\":[{\"HostPort\":\"443\"}]}}}"
}
}
},
"modules": {
"Sender": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULEDIR<../Sender>}",
"createOptions": "{}"
}
},
"Module1": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULEDIR<../Module1>}",
"createOptions": "{}"
}
},
"Module2": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULEDIR<../Module2>}",
"createOptions": "{}"
}
},
"Module11": {
"version": "1.0.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"settings": {
"image": "${MODULEDIR<../Module11>}",
"createOptions": "{}"
}
}
}
}
},
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.0",
"routes": {
"SenderToModule1": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'Module1' INTO BrokeredEndpoint(\"/modules/Module1/inputs/input\")",
"SenderToModule2": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'Module2' INTO BrokeredEndpoint(\"/modules/Module2/inputs/input\")",
"SenderToModule11": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'Module11' INTO BrokeredEndpoint(\"/modules/Module11/inputs/input\")",
"Module1ToModule11": "FROM /messages/modules/Module1/outputs/* INTO BrokeredEndpoint(\"/modules/Module11/inputs/input\")",
"SenderToHub": "FROM /messages/modules/Module1/outputs/* WHERE $body.Receiver = 'Hub' INTO $upstream"
},
"storeAndForwardConfiguration": {
"timeToLiveSecs": 7200
}
}
}
}
}
}
接下来,我尝试创建分层部署启动命令
az iot edge deployment create --layered --deployment-id deploy001 --hub-name <hubname> --content ./layeredtarget.json --target-condition "tags.deviceId='TargetDevice'" --priority 2
此处,layeredtarget.json 文件:
{
"content": {
"modulesContent": {
"$edgeHub": {
"properties.desired.routes.SenderToModule1": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'UPDATE_LAYERED' INTO BrokeredEndpoint(\"/modules/Module1/inputs/input\")"
}
}
}
}
通过启动 powershell 命令,我收到了这个错误:
{'Message': 'ErrorCode:InvalidConfigurationContent;The content provided for configuration is invalid. >Please check and try again', 'ExceptionMessage': 'Tracking ID:f716a3c452914ea4a1ad1ee958a7b2ff-G:5->TimeStamp:01/20/2021 16:14:15'}
我不明白我是否做错了。我关注了这个 Doc 有人知道吗?
如果您还包括 $edgeAgent
,您的分层部署将工作得很好。我所做的就是在门户中重新创建您的部署,检查 JSON 并注意到空的 edgeAgent。我想没有多少人只用一条路线来创建分层部署。不错的主意。我使用 CLI 在我的集线器上测试了下面的 JSON 并且它有效:
{
"content": {
"modulesContent": {
"$edgeAgent": {},
"$edgeHub": {
"properties.desired.routes.SenderToModule1": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'UPDATE_LAYERED' INTO BrokeredEndpoint(\"/modules/Module1/inputs/input\")"
}
}
}
}