你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。

Device Update - Import Update

导入新的更新版本。 这是长时间运行的作;使用 Operation-Location 响应标头值检查作状态。

POST https://{endpoint}/deviceUpdate/{instanceId}/updates:import?api-version=2026-06-01

URI 参数

名称 在 必需 类型 说明
endpoint
path True

string (url)

IoT 中心帐户终结点的设备更新(仅主机名,无协议)。

instanceId
path True

string

IoT 中心帐户实例标识符的设备更新。

api-version
query True

string

minLength: 1

用于此操作的 API 版本。

请求正文

名称 类型 说明
updateToImport

ImportUpdateInputItem[]

要导入的更新(有关详细信息,请参阅架构 https://json.schemastore.org/azure-deviceupdate-import-manifest-5.0.json)。

响应

名称 类型 说明
200 OK

Update

请求已成功。

202 Accepted

已接受请求进行处理,但尚未完成处理。

标头

Operation-Location: string

Other Status Codes

ErrorResponse

未预期的错误响应。

安全性

OAuth2Auth

类型: oauth2
流向: implicit
授权 URL: https://login.microsoftonline.com/common/oauth2/authorize

作用域

名称 说明
https://api.adu.microsoft.com/.default

示例

DeviceUpdate_ImportUpdate

示例请求

POST https://contoso.api.adu.microsoft.com/deviceUpdate/blue/updates:import?api-version=2026-06-01

[
  {
    "importManifest": {
      "url": "http://test.blob.core.windows.net/test/uploadimportMan.json",
      "sizeInBytes": 816,
      "hashes": {
        "sha256": "O19LyyncPe1AGstOdkcmozLV8pSbBdqrE18HdYVohRc="
      }
    },
    "files": [
      {
        "filename": "file1.bin",
        "url": "http://test.blob.core.windows.net/test/upload1v5uww1q"
      },
      {
        "filename": "file2.bin",
        "url": "http://test.blob.core.windows.net/test/uploadkrmn5yw0"
      },
      {
        "filename": "file3.bin",
        "url": "http://test.blob.core.windows.net/test/uploaddq52ky5m"
      }
    ]
  }
]

示例响应

Operation-Location: /deviceUpdate/blue/updates/operations/e4491c54-916f-443d-9094-bcca546ace2f?api-version=2026-06-01
{
  "updateId": {
    "provider": "microsoft",
    "name": "adu",
    "version": "1.0.0.0"
  },
  "friendlyName": "Lab Sensor Update v1",
  "description": "Fix for critical vulnerability",
  "compatibility": [
    {
      "deviceManufacturer": "Microsoft",
      "deviceModel": "Toaster"
    }
  ],
  "instructions": {
    "steps": [
      {
        "description": "pre-install script",
        "handler": "microsoft/script:1",
        "handlerProperties": {
          "arguments": "--pre-install"
        },
        "files": [
          "configure.sh"
        ]
      },
      {
        "type": "reference",
        "updateId": {
          "provider": "microsoft",
          "name": "sensor",
          "version": "1.0"
        }
      }
    ]
  },
  "manifestVersion": "5.0",
  "importedDateTime": "2020-04-22T14:01:43.8408797-07:00",
  "createdDateTime": "2019-09-11T17:00:00-07:00",
  "etag": "\"3fed3378-0c67-47d2-b796-296962c66cbb\""
}

定义

名称 说明
Error

错误详细信息。

ErrorResponse

常见的错误响应。

FileImportMetadata

描述更新文件的元数据。

ImportManifestMetadata

描述导入清单的元数据,描述有关更新版本的文件和其他元数据的文档。

ImportUpdateInputItem

导入更新输入项元数据。

InnerError

包含与当前对象有关错误的更具体信息的对象。

Instructions

更新安装说明容器。

Step

更新安装说明步骤。

StepType

步骤类型。

Update

更新元数据。

UpdateId

更新标识符。

Error

错误详细信息。

名称 类型 说明
code

string

服务器定义的错误代码。

details

Error[]

导致报告错误的错误的数组。

innererror

InnerError

包含与当前对象有关错误的更具体信息的对象。

message

string

有关错误的可读的表示形式。

occurredDateTime

string (date-time)

发生错误的日期和时间(UTC)。

target

string

错误的目标。

ErrorResponse

常见的错误响应。

名称 类型 说明
error

Error

错误详情。

FileImportMetadata

描述更新文件的元数据。

名称 类型 说明
filename

string

更新导入清单中指定的文件名。

url

string

可以通过 IoT 中心的设备更新从中下载更新文件的 Azure Blob 位置。 这通常是一个只读受 SAS 保护的 Blob URL,过期时间设置为至少 4 小时。

ImportManifestMetadata

描述导入清单的元数据,描述有关更新版本的文件和其他元数据的文档。

名称 类型 说明
hashes

object

包含文件的哈希(es)的 JSON 对象。 至少需要 SHA256 哈希。 可以将此对象视为一组键值对,其中键是哈希算法,该值是使用该算法计算的文件的哈希。

sizeInBytes

integer (int64)

文件大小(以字节数为单位)。

url

string

可从中下载导入清单的 Azure Blob 位置,供 IoT 中心的设备更新下载。 这通常是一个只读受 SAS 保护的 Blob URL,过期时间设置为至少 4 小时。

ImportUpdateInputItem

导入更新输入项元数据。

名称 类型 说明
files

FileImportMetadata[]

一个或多个更新文件属性,如文件名和源 URL。

friendlyName

string

minLength: 1
maxLength: 512

友好更新名称。

importManifest

ImportManifestMetadata

导入清单元数据,例如源 URL、文件大小/哈希等。

InnerError

包含与当前对象有关错误的更具体信息的对象。

名称 类型 说明
code

string

比包含的错误提供的错误代码更具体。

errorDetail

string

内部错误或异常消息。

innerError

InnerError

包含与当前对象有关错误的更具体信息的对象。

message

string

有关错误的可读的表示形式。

Instructions

更新安装说明容器。

名称 类型 说明
steps

Step[]

安装步骤的集合。

Step

更新安装说明步骤。

名称 类型 默认值 说明
description

string

minLength: 1
maxLength: 64

步骤说明。

files

string[]

在执行过程中要传递给处理程序的文件名的集合。 如果步骤类型为内联,则为必需。

handler

string

minLength: 1
maxLength: 32

将执行此步骤的处理程序的标识。 如果步骤类型为内联,则为必需。

handlerProperties

在执行过程中要传递给处理程序的参数。

type

StepType

inline

步骤类型。

updateId

UpdateId

引用的子更新标识。 如果引用步骤类型,则为必需。

StepType

步骤类型。

值 说明
inline

执行代码执行的步骤类型。

reference

安装另一个更新的步骤类型。

Update

更新元数据。

名称 类型 默认值 说明
compatibility

object[]

更新兼容性信息列表。

createdDateTime

string (date-time)

创建更新时的 UTC 日期和时间。

description

string

minLength: 1
maxLength: 512

更新创建者指定的说明。

etag

string

更新 ETag。

friendlyName

string

minLength: 1
maxLength: 512

导入程序指定的友好更新名称。

importedDateTime

string (date-time)

导入更新的 UTC 日期和时间。

installedCriteria

string

设备更新客户端解释的字符串,用于确定是否在设备上安装更新。 在最新的导入清单架构中弃用。

instructions

Instructions

更新安装说明。

isDeployable

boolean

True

更新是否可以自行部署到设备。

manifestVersion

string

用于导入更新的清单的架构版本。

referencedBy

UpdateId[]

引用此更新的更新标识列表。

scanResult

string

更新聚合扫描结果(根据有效负载文件扫描结果计算)。

updateId

UpdateId

更新标识。

updateType

string

更新类型。 在最新的导入清单架构中弃用。

UpdateId

更新标识符。

名称 类型 说明
name

string

更新名称。

provider

string

更新提供程序。

version

string

更新版本。