我知道如何创建AD B2C用户,以及如何通过图形API将他们添加到组中。我正在我的 Azure 函数中执行此操作。我想知道的是,是否可以创建用户并同时将他们添加到组中?如果没有,那么我想我将不得不处理正在创建用户但未能添加到组的潜在情况。这种情况的可能性有多大?我试图确保我涵盖了所有故障条件的所有基础,因此任何输入将不胜感激。谢谢。
您似乎想对此类请求使用批处理。
以下是他们在文章中发布的示例请求:以下示例显示包含五个项目的批处理请求:
- 创建用户 testuser@contoso.onmicrosoft.com (POST) 的更改集。此操作包括 Prefer: 无响应内容标头,以禁止返回新创建的用户。
- 更新新用户的部门和职务属性 (PATCH) 并设置其经理导航属性 (PUT) 的更改集。
- 对新用户 (GET) 的经理的查询。
- 删除新用户的更改集 (DELETE)。
-
对用户的查询 (GET)。此操作将失败,因为在上一步中删除了用户。
POST https://graph.windows.net/contoso.onmicrosoft.com/$batch?api-version=1.5 HTTP/1.1 Authorization: Bearer ey … jQA Content-Type: multipart/mixed; boundary=batch_36522ad7-fc75-4b56-8c71-56071383e77b Host: graph.windows.net Content-Length: 2961 --batch_36522ad7-fc75-4b56-8c71-56071383e77b Content-Type: multipart/mixed; boundary=changeset_77162fcd-b8da-41ac-a9f8-9357efbbd620 Content-Length: 631 --changeset_77162fcd-b8da-41ac-a9f8-9357efbbd620 Content-Type: application/http Content-Transfer-Encoding: binary POST /contoso.onmicrosoft.com/users?api-version=1.5 HTTP/1.1 Content-Type: application/json Accept: application/json Content-Length: 256 Prefer: return-no-content Host: graph.windows.net { "accountEnabled": true, "displayName": "Test User", "mailNickname": "testuser", "passwordProfile": { "password" : "Test1234", "forceChangePasswordNextLogin": false }, "userPrincipalName": "testuser@contoso.onmicrosoft.com" } --changeset_77162fcd-b8da-41ac-a9f8-9357efbbd620----batch_36522ad7-fc75-4b56-8c71-56071383e77b Content-Type: multipart/mixed; boundary=changeset_4b2cbfb7-011d-4edb-8bbf-e044f9830aaf Content-Length: 909 --changeset_4b2cbfb7-011d-4edb-8bbf-e044f9830aaf Content-Type: application/http Content-Transfer-Encoding: binary PATCH /contoso.onmicrosoft.com/users/testuser@contoso.onmicrosoft.com?api-version=1.5 HTTP/1.1 Content-Type: application/json Accept: application/json Content-Length: 72 Host: graph.windows.net { "department": "Engineering", "jobTitle": "Test Engineer" } --changeset_4b2cbfb7-011d-4edb-8bbf-e044f9830aaf Content-Type: application/http Content-Transfer-Encoding: binary PUT /contoso.onmicrosoft.com/users/testuser@contoso.onmicrosoft.com/$links/manager?api-version=1.5 HTTP/1.1 Content-Type: application/json Accept: application/json Content-Length: 112 Host: graph.windows.net { "url":"https://graph.windows.net/contoso.onmicrosoft.com/users/a71e4d1c-ce99-40dc-8d4b-390eac63e039" } --changeset_4b2cbfb7-011d-4edb-8bbf-e044f9830aaf----batch_36522ad7-fc75-4b56-8c71-56071383e77b Content-Type: application/http Content-Transfer-Encoding:binary GET /contoso.onmicrosoft.com/users/testuser@contoso.onmicrosoft.com/$links/manager?api-version=1.5 HTTP/1.1 Accept: application/json Host: graph.windows.net --batch_36522ad7-fc75-4b56-8c71-56071383e77b Content-Type: multipart/mixed; boundary=changeset_9a0b5878-0f4a-4f57-91c5-9792cdd5ef20 Content-Length: 331 --changeset_9a0b5878-0f4a-4f57-91c5-9792cdd5ef20 Content-Type: application/http Content-Transfer-Encoding: binary DELETE /contoso.onmicrosoft.com/users/testuser@contoso.onmicrosoft.com?api-version=1.5 HTTP/1.1 Accept: application/json Host: graph.windows.net --changeset_9a0b5878-0f4a-4f57-91c5-9792cdd5ef20----batch_36522ad7-fc75-4b56-8c71-56071383e77b Content-Type: application/http Content-Transfer-Encoding:binary GET /contoso.onmicrosoft.com/users/testuser@contoso.onmicrosoft.com?api-version=1.5 HTTP/1.1 Accept: application/json Host: graph.windows.net --batch_36522ad7-fc75-4b56-8c71-56071383e77b--