You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Microsoft Graph API高效获取多平台设备的已安装应用

替代方案获取全平台已安装应用(Microsoft Graph API)

方案一:直接查询detectedApps并关联设备

无需先遍历所有设备,可直接调用detectedApps接口,通过$expand关联设备信息,同时筛选目标平台:

GET https://graph.microsoft.com/v1.0/deviceManagement/detectedApps?$expand=managedDevices&$filter=managedDevices/operatingSystem in ('iOS', 'iPadOS', 'Android', 'Windows')

该请求会返回所有检测到的应用及其关联设备数据,单次请求即可覆盖目标平台的所有设备应用信息,大幅减少接口调用次数。

方案二:使用批量请求聚合调用

若需保留设备遍历逻辑,可借助Graph的批量请求接口,将最多20个独立API调用打包为单次请求,降低HTTP请求频次:

POST https://graph.microsoft.com/v1.0/$batch
Content-Type: application/json

{
  "requests": [
    {
      "id": "1",
      "method": "GET",
      "url": "/deviceManagement/manageddevices('device_id_1')?$expand=detectedApps"
    },
    {
      "id": "2",
      "method": "GET",
      "url": "/deviceManagement/manageddevices('device_id_2')?$expand=detectedApps"
    }
    // 最多可添加至20个请求
  ]
}

将设备ID分批打包,每批20个,可将调用次数压缩至原来的1/20。

方案三:通过导出作业异步获取大规模数据

针对上万台级别的超大规模设备,推荐使用Graph的导出功能,异步生成包含设备与应用数据的CSV文件后下载:

  1. 创建导出作业:
POST https://graph.microsoft.com/v1.0/deviceManagement/reports/exportJobs
Content-Type: application/json

{
  "reportName": "DetectedAppsByDevice",
  "filter": "operatingSystem in ('iOS', 'iPadOS', 'Android', 'Windows')",
  "select": "deviceName, deviceId, operatingSystem, appDisplayName, appVersion, publisher",
  "format": "csv"
}
  1. 轮询作业状态,直到状态变为completed:
GET https://graph.microsoft.com/v1.0/deviceManagement/reports/exportJobs('job_id')
  1. 下载文件:使用返回的url字段直接下载生成的CSV文件。

原manageddevices?$expand=detectedApps失效原因

该接口默认不支持批量展开所有设备的detectedApps,因单请求数据量过大,Graph API会限制此类操作,因此需采用上述替代方案。

内容的提问来源于stack exchange,提问作者Search

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 14:55:30