0

I'm very new to Azure IoT Edge and I'm trying to deploy to my Raspberry PI : Image Recognition with Azure IoT Edge and Cognitive Services but after Build & Push IoT Edge Solution and Deploy it to Single Device ID I see none of those 2 modules listed in Docker PS -a & Iotedge list And when try to check it on EdgeAgent Logs there's error message and it seems EdgeAgent get error while creating those Modules (camera-capture and image-classifier-service)

I've tried : 1. Re-build it from fresh folder package 2. Pull the image manually from Azure Portal and run the image manually by script

I'm stuck on this for days.

in deployment.arm32v7.json for those modules I define the Image with registered registry url :

"modules": {
          "camera-capture": {
            "version": "1.0",
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
              "image": "zzzz.azurecr.io/camera-capture-opencv:1.1.12-arm32v7",
              "createOptions": "{\"Env\":[\"Video=0\",\"azureSpeechServicesKey=2f57f2d9f1074faaa0e9484e1f1c08c1\",\"AiEndpoint=http://image-classifier-service:80/image\"],\"HostConfig\":{\"PortBindings\":{\"5678/tcp\":[{\"HostPort\":\"5678\"}]},\"Devices\":[{\"PathOnHost\":\"/dev/video0\",\"PathInContainer\":\"/dev/video0\",\"CgroupPermissions\":\"mrw\"},{\"PathOnHost\":\"/dev/snd\",\"PathInContainer\":\"/dev/snd\",\"CgroupPermissions\":\"mrw\"}]}}"
            }
          },
          "image-classifier-service": {
            "version": "1.0",
            "type": "docker",
            "status": "running",
            "restartPolicy": "always",
            "settings": {
              "image": "zzzz.azurecr.io/image-classifier-service:1.1.5-arm32v7",
              "createOptions": "{\"HostConfig\":{\"Binds\":[\"/home/pi/images:/images\"],\"PortBindings\":{\"8000/tcp\":[{\"HostPort\":\"80\"}],\"5679/tcp\":[{\"HostPort\":\"5679\"}]}}}"
            }

Error message from EdgeAgent Logs :

(Inner Exception #0) Microsoft.Azure.Devices.Edge.Agent.Edgelet.EdgeletCommunicationException- Message:Error calling Create module
image-classifier-service: Could not create module image-classifier-service
        caused by: Could not pull image zzzzz.azurecr.io/image-classifier-service:1.1.5-arm32v7
        caused by: Get https://zzzzz.azurecr.io/v2/image-classifier-service/manifests/1.1.5-arm32v7: unauthorized: authentication required

When trying to run the pulled image by script :

sudo docker run --rm --name testName -it zzzz.azurecr.io/camera-capture-opencv:1.1.12-arm32v7

None

I get this error :

Camera Capture Azure IoT Edge Module. Press Ctrl-C to exit.
Error: Time:Fri May 24 10:01:09 2019 File:/usr/sdk/src/c/iothub_client/src/iothub_client_core_ll.c Func:retrieve_edge_environment_variabes Line:191 Environment IOTEDGE_AUTHSCHEME not set
Error: Time:Fri May 24 10:01:09 2019 File:/usr/sdk/src/c/iothub_client/src/iothub_client_core_ll.c Func:IoTHubClientCore_LL_CreateFromEnvironment Line:1572 retrieve_edge_environment_variabes failed
Error: Time:Fri May 24 10:01:09 2019 File:/usr/sdk/src/c/iothub_client/src/iothub_client_core.c Func:create_iothub_instance Line:941 Failure creating iothub handle
Unexpected error IoTHubClient.create_from_environment, IoTHubClientResult.ERROR from IoTHub
silent
  • 14,494
  • 4
  • 46
  • 86
  • When you pulled it with docker run, it pulled but then failed to run outside of the edge runtime which is expected. But when the edge agent tried to pull it, it failed due to authorization. Did you add your zzzz.azurecr.io credentials to the deployment? – Damon Barry May 24 '19 at 15:11
  • As Damon said: Do you have a `registryCredentials` in your deployment.json? https://learn.microsoft.com/en-us/azure/iot-edge/module-composition#configure-modules – silent May 27 '19 at 14:28
  • Hi Damon & Silent, thanks for you reply, yes I've add the credential into my deployment.arm32v7.json : "registryCredentials": { "techlabid":{ "username": "${my registry Username}", "password": "${my registry Password}", "address": "https://zzzz.azurecr.io/" } is there anything wrong with that ? – Christianto Hermawan May 28 '19 at 03:33
  • Sorry I've just found that given registry credential is not correct - compared with given link. It should be direct value like Username : myusername without ${} I re-build and re-deploy it and it works now. thanks to you guys – Christianto Hermawan May 28 '19 at 10:19

1 Answers1

1

When you pulled the image directly with docker run, it pulled but then failed to run outside of the edge runtime, which is expected. But when the edge agent tried to pull it, it failed because it was not authorized. No credentials were supplied to the runtime, so it attempted to access the registry anonymously.

Make sure that you add your container registry credentials to the deployment so that edge runtime can pull images. The deployment should contain something like the following in the runtime settings:

"MyRegistry" :{
  "username": "<username>",
  "password": "<password>",
  "address": "<registry-name>.azurecr.io"
}

As @silent pointed out in the comments, the documentation is here, including an example deployment that includes container registry credentials.

Damon Barry
  • 261
  • 1
  • 4