I'm working on developing an MQTT broker written in Rust, and I need to deploy it to Azure to run up there. I have successfully built a Docker image of my code and everything seems to be functioning as intended.
Now I'm trying to take my Docker image and deploy it to a module inside of an Azure IoT Edge Device. I was able to upload my Docker image to my Azure Container Registry.
My issues arise after I make a deployment configuration for my Edge Device. Below is my deployment.json file.
{
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"schemaVersion": "1.1",
"runtime": {
"type": "docker",
"settings": {
"registryCredentials": {
"My-Container-Registry": {
"address": "<My-Container-Registry>.azurecr.io",
"password": "pass",
"username": "username"
}
}
}
},
"systemModules": {
"edgeAgent": {
"settings": {
"image": "mcr.microsoft.com/azureiotedge-agent:1.4"
},
"type": "docker"
},
"edgeHub": {
"restartPolicy": "always",
"settings": {
"image": "mcr.microsoft.com/azureiotedge-hub:1.4",
"createOptions": "{\"HostConfig\":{\"PortBindings\":{\"443/tcp\":[{\"HostPort\":\"443\"}],\"5671/tcp\":[{\"HostPort\":\"5671\"}],\"8883/tcp\":[{\"HostPort\":\"8883\"}]}}}"
},
"status": "running",
"type": "docker"
}
},
"modules": {
"BrokerModule": {
"env": {
"IP_ADDR": {
"value": "0.0.0.0"
},
"LOGGING_LEVEL": {
"value": "Debug"
}
},
"imagePullPolicy": "on-create",
"restartPolicy": "always",
"settings": {
"image": "<My-Container-Registry>.azurecr.io/docker-mqtt-image:latest",
"createOptions": "{\"Cmd\":[\"Eula=accept\"],\"HostConfig\":{\"PortBindings\":{\"1883/tcp\":[{\"HostPort\":\"1883\"}]}}}"
},
"startupOrder": 3,
"status": "running",
"type": "docker"
}
}
}
},
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.1",
"storeAndForwardConfiguration": {
"timeToLiveSecs": 7200
},
"routes": {
"route1": {
"priority": 1,
"route": "FROM /messages/* INTO $upstream",
"timeToLiveSecs": 7200
}
}
}
}
}
}
I am able to use the Azure IoT Edge Extension for Visual Studio Code to deploy to my device and the deployment succeeds. However, when I look at the modules in Docker Desktop, the edgeAgent and edgeHub modules resart every second or so. Below are some screenshots of what I can see inside the Azure portal.
I believe that I have my custom module 'BrokerModule' figured out as it is running normally from what I can see in Docker Desktop. It is just the edgeAgent and edgeHub that are not behaving as intended. Please let me know if any more information is needed, any suggestions are welcome.
The logs for the edgeAgent and edgeHub are as follows:
edgeAgent:
2023-12-11 16:52:36 Starting Edge Agent
2023-12-11 16:52:36 Changing ownership of storage folder: /tmp/edgeAgent to 13622
2023-12-11 16:52:36 Changing ownership of backup folder: /tmp/edgeAgent_backup to 13622
2023-12-11 16:52:36 Completed necessary setup. Starting Edge Agent.
2023-12-11 16:52:36.758 +00:00 Edge Agent Main()
<6> 2023-12-11 16:52:36.953 +00:00 [INF] [Microsoft.Azure.Devices.Edge.Agent.Service.Program] - Initializing Edge Agent.
<6> 2023-12-11 16:52:37.095 +00:00 [INF] [Microsoft.Azure.Devices.Edge.Agent.Service.Program] - Version - 1.4.25.82955152 (8846287bfff028b19016e7d69f988d4dce3a802a)
<6> 2023-12-11 16:52:37.095 +00:00 [INF] [Microsoft.Azure.Devices.Edge.Agent.Service.Program] -
█████╗ ███████╗██╗ ██╗██████╗ ███████╗
██╔══██╗╚══███╔╝██║ ██║██╔══██╗██╔════╝
███████║ ███╔╝ ██║ ██║██████╔╝█████╗
██╔══██║ ███╔╝ ██║ ██║██╔══██╗██╔══╝
██║ ██║███████╗╚██████╔╝██║ ██║███████╗
╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
██╗ ██████╗ ████████╗ ███████╗██████╗ ██████╗ ███████╗
██║██╔═══██╗╚══██╔══╝ ██╔════╝██╔══██╗██╔════╝ ██╔════╝
██║██║ ██║ ██║ █████╗ ██║ ██║██║ ███╗█████╗
██║██║ ██║ ██║ ██╔══╝ ██║ ██║██║ ██║██╔══╝
██║╚██████╔╝ ██║ ███████╗██████╔╝╚██████╔╝███████╗
╚═╝ ╚═════╝ ╚═╝ ╚══════╝╚═════╝ ╚═════╝ ╚══════╝
<6> 2023-12-11 16:52:37.097 +00:00 [INF] [Microsoft.Azure.Devices.Edge.Agent.Service.Program] - ModuleUpdateMode: NonBlocking
<6> 2023-12-11 16:52:37.164 +00:00 [INF] [Microsoft.Azure.Devices.Edge.Agent.Service.Program] - Experimental features configuration: {"Enabled":false,"DisableCloudSubscriptions":false}
<0> 2023-12-11 16:52:37.183 +00:00 [FTL] [Microsoft.Azure.Devices.Edge.Agent.Service.Program] - Fatal error building application. System.ArgumentNullException: Value cannot be null. (Parameter 'uriString')
at System.Uri..ctor(String uriString)
at Microsoft.Azure.Devices.Edge.Agent.Service.Program.MainAsync(IConfiguration configuration) in /mnt/vss/_work/1/s/edge-agent/src/Microsoft.Azure.Devices.Edge.Agent.Service/Program.cs:line 176
edgeHub:
2023-12-11 16:36:32 Starting Edge Hub
2023-12-11 16:36:32 Starting Edge Hub
2023-12-11 16:36:32 Changing ownership of storage folder: /tmp/edgeHub to 13623
2023-12-11 16:36:32 Changing ownership of backup folder: /tmp/edgeHub_backup to 13623
2023-12-11 16:36:32.646 +00:00 Edge Hub Main()
<3> 2023-12-11 16:36:32.803 +00:00 [ERR] - Stopping with exception System.ArgumentNullException: Value cannot be null. (Parameter 'uriString') at System.Uri..ctor(String uriString)
at Microsoft.Azure.Devices.Edge.Hub.Service.EdgeHubCertificates.LoadAsync(IConfigurationRoot configuration, ILogger logger) in /mnt/vss/_work/1/s/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/EdgeHubCertificates.cs:line 50
at Microsoft.Azure.Devices.Edge.Hub.Service.Program.MainAsync(IConfigurationRoot configuration) in /mnt/vss/_work/1/s/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs:line 58
Unhandled exception. System.AggregateException: One or more errors occurred. (Value cannot be null. (Parameter 'uriString'))
---> System.ArgumentNullException: Value cannot be null. (Parameter 'uriString')
at System.Uri..ctor(String uriString)
at Microsoft.Azure.Devices.Edge.Hub.Service.EdgeHubCertificates.LoadAsync(IConfigurationRoot configuration, ILogger logger) in /mnt/vss/_work/1/s/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/EdgeHubCertificates.cs:line 50
at Microsoft.Azure.Devices.Edge.Hub.Service.Program.MainAsync(IConfigurationRoot configuration) in /mnt/vss/_work/1/s/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs:line 58
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at System.Threading.Tasks.Task`1.get_Result()
at Microsoft.Azure.Devices.Edge.Hub.Service.Program.Main() in /mnt/vss/_work/1/s/edge-hub/core/src/Microsoft.Azure.Devices.Edge.Hub.Service/Program.cs:line 35