Error importing an update

AZ ADM Steffens, Martin 0 Reputation points
2024-02-12T08:54:49.0466667+00:00

I'm currently testing the Device Update Service. As a first step I try to upload a simple Python file to a device. However, I keep getting the following error message when importing the update into the IoT Hub: Import manifest contains invalid data. (Field 'Files' has invalid data in one of its items.) The relevant location in the maifest file looks like this: "files": [ { "filename": "HelloWorld.py", "sizeInBytes": 24, "hashes": { "sha256": "0777d4c83a32cb91b7b2dcf87a72af4ace65e64525469b70f38854553a65dada" } } The Hash value and size should be correct. What can be the root cause of the problem?

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,134 questions
{count} votes

2 answers

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 13,791 Reputation points
    2024-02-12T22:34:35.6+00:00

    Hi @AZ ADM Steffens, Martin Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here and sharing additional information on your manifest file. I have a few observations based on the data provided in the file.

    sizeInBytes

    The value for the file seems to be too small for a Python file. You can validate the file size by running the following command from command prompt or VS Code terminal wc -c HelloWorld.py

    sha256

    Can you please confirm the steps you have followed in generating this hash value? To calculate the hash correctly for your update file, you can use the function Get-AduFileHashes from the AduUpdate.psm1 script I have tested the function from my Windows PowerShell as following and notice the file hash value I get for my file. User's image

    The value you are using does not seem to have any special characters in the generated hash.

    handler

    I see that you are using the handler in the steps section as python/update:1. Update handlers are used to invoke installers or commands to do an over-the-air update. You can either use existing update content handlers or implement a custom content handler that can invoke any installer and execute the over-the-air update needed for your use case. If you decide to use a custom handler, which is what you are doing, make sure you implement the handler.

    Hope this helps. If you still need any assistance or run into further issues, please do not hesitate to reach out to us through the comments below. We would be happy to assist you.


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.

    0 comments No comments

  2. Steffens, Martin 0 Reputation points
    2024-02-13T09:56:31.86+00:00

    Hello LeelaRajeshSayana-MSFT. Thank you for your information. Regarding my simple test-Python file the small size is correct. The content of this file is just:

    print("Hello, world!")
    

    I still had an empty line in this file that I deleted. Now the file above has a size of 22 bytes. I checked this via Powershell: (Get-Item HelloWorld.py).length 22 Regarding the Hash value I used: Get-FileHash -Path ".\HelloWorld.py" -Algorithm SHA256 Result is now: CF205E0333AB48738D1255AB51757560B059421B882EDD666D9B06F1E7DFBF9F I changed the handler in the manifest file with the existing handler: "microsoft/update:1" My manifest now is now:

    {
      "updateId": {
        "provider": "nxBrake",
        "name": "PythonUpdate",
        "version": "1.0"
      },
      "compatibility": [
        {
          "manufacturer": "nxBrake",
          "model": "RPi4"
        }
      ],
      "instructions": {
        "steps": [
          {
            "handler": "microsoft/update:1",
            "files": [
              "HelloWorld.py"
            ],
            "handlerProperties": {
              "installedCriteria": "1.0"
            }
          }
        ]
      },
      "files": [
        {
          "filename": "HelloWorld.py",
          "sizeInBytes": 22,
          "hashes": {
            "sha256": "CF205E0333AB48738D1255AB51757560B059421B882EDD666D9B06F1E7DFBF9F"
          }
        }
      ],
      "createdDateTime": "2024-01-19T06:23:52.6996916Z",
      "manifestVersion": "5.0"
    }
    

    But I still get the same error as before when I try to import the Update : Import manifest contains invalid data. (Field 'Files' has invalid data in one of its items.)

    0 comments No comments