Error deploying Azure IoT Edge Device: EdgeHub and EdgeAgent modules fail to start with ArgumentNullException: Value cannot be null. (Parameter 'uriString')

Toole, Cian 45 Reputation points
2023-12-11T17:07:24.7366667+00:00

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.

deployment

device

troubleshooter

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
Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
391 questions
Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
557 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,149 questions
0 comments No comments
{count} votes

Accepted answer
  1. LeelaRajeshSayana-MSFT 13,951 Reputation points
    2023-12-12T01:19:57.92+00:00

    Hi @Toole, Cian Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    Did you get a chance to see if the IoT Edge Agent is running on the device before you deployed this module? The error message implied that the IoT Edge runtime is trying to load certificates for the device and fails. Can you please confirm the attestation mechanism you are using for the device on IoT Hub? If you are using X509 certificate as authentication mechanism, can you please confirm if you configured the config.toml file with the correct paths of identity-cert and identity_pk parameters? You should add the settings in the Maula provisioning section as follows.

    # Manual provisioning with x.509 certificates
    [provisioning]
    source = "manual"
    iothub_hostname = "REQUIRED_IOTHUB_HOSTNAME"
    device_id = "REQUIRED_DEVICE_ID_PROVISIONED_IN_IOTHUB"
    
    [provisioning.authentication]
    method = "x509"
    
    identity_cert = "REQUIRED_URI_OR_POINTER_TO_DEVICE_IDENTITY_CERTIFICATE"
    
    identity_pk = "REQUIRED_URI_TO_DEVICE_IDENTITY_PRIVATE_KEY"
    
    

    Please refer the article Provision the device with its cloud identity for more details on this.

    I believe that I have my custom module 'BrokerModule' figured out as it is running normally

    I would like to clarify that your Module is down too. Without the Edge Agent and Edge Hub running, your module would not be able to connect to IoT Hub. You can see from the runtime status of IoT Edge device that all modules are reporting error and none of them are running.

    If the above information does not help you address the issue, kindly let us know the system configurations such as hosting machine OS type, it's version and the IoT edge device authentication type to help us better understand the issue. I would also like you to test and see if the Edge Agent module runs and could connect to IoT Hub when you remove the BrokerModule from the deployment.

    Please keep us posted on your findings.


0 additional answers

Sort by: Most helpful