I'm try to create a layered deploy for an Azure IoT Hub.
Base full deployment goes ok. Here the configuration:
{
"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
}
}
}
}
}
}
Next, I've tried to create a layered deployment launching command
az iot edge deployment create --layered --deployment-id deploy001 --hub-name <hubname> --content ./layeredtarget.json --target-condition "tags.deviceId='TargetDevice'" --priority 2
Here, the layeredtarget.json file:
{
"content": {
"modulesContent": {
"$edgeHub": {
"properties.desired.routes.SenderToModule1": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'UPDATE_LAYERED' INTO BrokeredEndpoint(\"/modules/Module1/inputs/input\")"
}
}
}
}
By launching powershell command i've received this error:
{'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'}
I don't understand were i did a mistake. I followed this Doc Does someone has any idea?
If you also include the $edgeAgent
, your layered deployment will work just fine. What I did to find this out was to re-create your deployment in the portal, checked the JSON and noticed the empty edgeAgent. I guess not many people are creating layered deployments with just a route. Neat idea though. I tested the JSON below on my hub using the CLI and it worked:
{
"content": {
"modulesContent": {
"$edgeAgent": {},
"$edgeHub": {
"properties.desired.routes.SenderToModule1": "FROM /messages/modules/Sender/outputs/* WHERE $body.Receiver = 'UPDATE_LAYERED' INTO BrokeredEndpoint(\"/modules/Module1/inputs/input\")"
}
}
}
}