Azure AD Graph API:批量更新用户
Azure AD Graph API: Bulk update of users
Azure AD Graph API 是否支持对用户进行批处理?例如,如果我想更新组织中数百个用户的位置,有什么办法可以做到吗?我能找到的唯一信息是这里描述的内容:https://msdn.microsoft.com/en-us/library/azure/ad/graph/howto/azure-ad-graph-api-batch-processing
但据我了解,在给定的批处理操作中,您只能对单个用户实体进行批处理操作,甚至每个变更集也仅限于 5 个操作。所以我唯一的选择似乎是顺序调用 API 来更新我列表中的每个用户。我找不到任何可能由 Microsoft 强制执行的官方记录的速率限制。所以我不确定这种方法是否有效。有更好的方法吗?
是的,Azure AD Graph API 支持对用户进行批处理。请参考 this code sample,检查该代码示例中的 CreateUsersTest
函数。要使该示例正常工作,您需要为您的客户端应用程序添加 Read and write directory data
应用程序权限:
另一种方法是使用 powershell 通过批量导入过程添加多个用户:
首先创建一个具有适当属性的 csv 文件,例如:
连接服务:
PS C:\WINDOWS\system32> connect-msolservice
从 csv 文件导入用户:
$users = Import-Csv E:\a.csv
使用 New-MsolUser
命令创建用户。
$users | ForEach-Object {New-MsolUser -UserPrincipalName $_.UserName -FirstName $_.FirstName -LastName $_.LastName –DisplayName $_.DisplayName -Title $_.JobTitle -Department $_.Department -Country $_.Country}
更新:
请参考文档:https://msdn.microsoft.com/en-us/library/azure/ad/graph/howto/azure-ad-graph-api-batch-processing
The Graph API supports a subset of the functionality defined by the OData specification:
A single batch can contain a maximum of five queries and/or change sets combined.
A change set can contain a maximum of one source object modification and up to 20 add-link and delete-link operations combined. All operations in the change set must be on a single source entity.
在您的场景中,单个源实体意味着一个用户实体,您可以创建一个用户,在更改集中修改该用户,但不能在一个更改集中创建两个用户,因为他们是两个实体.
似乎没有这样的文件列出批处理的速率限制,但我已经测试过使用上面的代码创建 2000 多个用户并且它工作正常。
Azure AD Graph API 是否支持对用户进行批处理?例如,如果我想更新组织中数百个用户的位置,有什么办法可以做到吗?我能找到的唯一信息是这里描述的内容:https://msdn.microsoft.com/en-us/library/azure/ad/graph/howto/azure-ad-graph-api-batch-processing
但据我了解,在给定的批处理操作中,您只能对单个用户实体进行批处理操作,甚至每个变更集也仅限于 5 个操作。所以我唯一的选择似乎是顺序调用 API 来更新我列表中的每个用户。我找不到任何可能由 Microsoft 强制执行的官方记录的速率限制。所以我不确定这种方法是否有效。有更好的方法吗?
是的,Azure AD Graph API 支持对用户进行批处理。请参考 this code sample,检查该代码示例中的 CreateUsersTest
函数。要使该示例正常工作,您需要为您的客户端应用程序添加 Read and write directory data
应用程序权限:
另一种方法是使用 powershell 通过批量导入过程添加多个用户:
首先创建一个具有适当属性的 csv 文件,例如:
连接服务:
PS C:\WINDOWS\system32> connect-msolservice
从 csv 文件导入用户:
$users = Import-Csv E:\a.csv
使用
New-MsolUser
命令创建用户。$users | ForEach-Object {New-MsolUser -UserPrincipalName $_.UserName -FirstName $_.FirstName -LastName $_.LastName –DisplayName $_.DisplayName -Title $_.JobTitle -Department $_.Department -Country $_.Country}
更新:
请参考文档:https://msdn.microsoft.com/en-us/library/azure/ad/graph/howto/azure-ad-graph-api-batch-processing
The Graph API supports a subset of the functionality defined by the OData specification:
A single batch can contain a maximum of five queries and/or change sets combined.
A change set can contain a maximum of one source object modification and up to 20 add-link and delete-link operations combined. All operations in the change set must be on a single source entity.
在您的场景中,单个源实体意味着一个用户实体,您可以创建一个用户,在更改集中修改该用户,但不能在一个更改集中创建两个用户,因为他们是两个实体.
似乎没有这样的文件列出批处理的速率限制,但我已经测试过使用上面的代码创建 2000 多个用户并且它工作正常。