다음을 통해 공유


관련 파일 기능을 사용하여 여러 업데이트 파일 참조

단일 업데이트에서 서로 다른 업데이트 파일 간의 관계를 표현해야 하는 경우 관련 파일 기능을 사용합니다.

Device Update for IoT Hub로 업데이트를 가져올 때 업데이트 페이로드에 대한 메타데이터를 포함하는 가져오기 매니페스트가 필요합니다. 가져오기 매니페스트의 파일 수준 메타데이터는 가장 간단한 경우 업데이트 페이로드 파일의 단순 목록일 수 있습니다. 그러나 고급 시나리오의 경우 관련 파일 기능을 통해 여러 업데이트 파일 간의 관계를 지정할 수 있습니다.

관련 파일 기능을 사용하여 가져오기 매니페스트를 만들 때 하나 이상의 기본 페이로드 파일에 관련 파일 컬렉션을 추가할 수 있습니다. 이 개념의 예는 관련 파일을 사용하여 전체 이미지 파일과 연결된 델타 업데이트를 지정하는 Device Update 델타 업데이트 기능입니다. 델타 시나리오에서 관련 파일 기능을 사용하면 전체 이미지와 델타 업데이트를 모두 단일 업데이트 작업으로 가져온 다음 둘 중 하나를 디바이스에 배포할 수 있습니다. 그러나 관련 파일 기능은 고유한 시나리오에 따라 고객이 확장할 수 있도록 설계되었기 때문에 델타 업데이트로 제한되지 않습니다.

관련 파일 기능은 버전 5 이상의 가져오기 매니페스트에 사용할 수 있습니다.

가져오기 매니페스트에 관련 파일을 추가할 때 다음 정보를 포함합니다.

  • 파일 세부 정보

    파일 이름, 크기 및 해시를 제공하여 관련 파일을 정의합니다.

  • 다운로드 처리기

    이러한 관련 파일을 처리하여 대상 파일을 생성하는 방법을 지정합니다. 가져오기 매니페스트에 downloadHandler 속성을 포함하여 처리 방법을 지정합니다. file 요소에서 relatedFiles의 비어 있지 않은 컬렉션을 지정하는 경우 downloadHandler를 포함해야 합니다. 간단한 id 속성을 사용하여 downloadHandler를 지정할 수 있습니다. 다운로드 처리기 id의 ASCII 문자는 64자로 제한됩니다.

  • 관련 파일 속성

    디바이스의 업데이트 처리기에 대한 추가 메타데이터를 제공하여 관련 파일로 지정한 파일을 해석하고 적절하게 사용하는 방법을 알 수 있습니다. 이 메타데이터는 properties 속성 모음의 일부로 filerelatedFile 개체에 추가됩니다.

관련 파일의 가져오기 스키마에 대한 자세한 내용은 relatedFiles 개체를 참조하세요.

다음 샘플 가져오기 매니페스트는 관련 파일 기능을 사용하여 델타 업데이트를 가져오는 방법을 보여 줍니다. 이 예에서는 files 섹션에 properties 항목으로 지정된 전체 이미지(full-image-file-name)가 있음을 볼 수 있습니다. 그러면 properties 항목 아래에 연결된 relatedFiles 항목이 있습니다. relatedFiles 섹션 내에서 델타 업데이트 파일(delta-from-v1-file-name)에 대한 또 다른 properties 섹션과 적절한 id가 나열된 downloadHandler 항목(microsoft/delta:1)을 볼 수 있습니다.

참고 항목

이 예에서는 델타 업데이트를 사용하여 관련 파일을 참조하는 방법을 보여 줍니다. 델타 업데이트를 기능으로 사용하려면 델타 업데이트 설명서에서 자세히 알아봅니다.

    {
      "updateId": {
        // provider, name, version
      },
      "compatibility": [
        {
          // manufacturer, model, etc.
        }
      ],
      "instructions": {
        "steps": [
          // Inline steps...
        ]
      },
      "files": [
        {  
          // standard file properties
          "fileName": "full-image-file-name",
          "sizeInBytes": 12345,
          "hashes": {
            "SHA256": "full-image-file-hash"
          },
          "mimeType": "application/octet-stream",
          // new properties
          "properties  ": {},
          "relatedFiles": [
            {
              // delta from version 1.0.0.0
              // standard file properties
              "fileName": "delta-from-v1-file-name",
              "sizeInBytes": 1234,
              "hashes": {
                "SHA256": "delta-from-v1-file-hash"
              },
              "mimeType": "application/octet-stream",
              // new properties
              "properties": {
                "microsoft.sourceFileHash": "delta-source-file-hash",
                "microsoft.sourceFileHashAlgorithm": "sha256"
              }
            }  
          ],
          // handler to download/process our related files
      "downloadHandler": {
        "id": "microsoft/delta:1"
      }
    }
  ],
  "createdDateTime": "2021-12-01T01:12:21Z",
  "manifestVersion": "5.0"
    }

가져오기 매니페스트를 만들기 위한 az iot du init v5 명령은 선택적 --related-file 매개 변수를 지원합니다.

--related-file 매개 변수는 pathproperties 키를 사용합니다.

--related-file path=<replace with path(s) to your delta file(s), including the full file name> properties='{"microsoft.sourceFileHashAlgorithm": "sha256", "microsoft.sourceFileHash": "<replace with the source SWU image file hash>"}' 

예시:

az iot du update init v5 \
--update-provider Microsoft --update-name myBundled --update-version 2.0 \
--compat manufacturer=Contoso model=SpaceStation \
--step handler=microsoft/script:1 properties='{"arguments": "--pre"}' description="Pre-install script" \
--file path=/my/update/scripts/preinstall.sh downloadHandler=microsoft/delta:1 \
--related-file path=/my/update/scripts/related_preinstall.json properties='{"microsoft.sourceFileHashAlgorithm": "sha256"}' \
--step updateId.provider=Microsoft updateId.name=SwUpdate updateId.version=1.1 \
--step handler=microsoft/script:1 properties='{"arguments": "--post"}' description="Post-install script" \
--file path=/my/update/scripts/postinstall.sh

다음 단계