简体   繁体   English

Azure AD B2C REST API:创建批量本地帐户

[英]Azure AD B2C REST API : Create Bulk Local Accounts

Is it possible to create users in bulk via the REST API.是否可以通过 REST API 批量创建用户。 Same as we do for single user in the below URL.与我们在以下 URL 中为单个用户所做的相同。

https://graph.windows.net/ {MYADB2C}.onmicrosoft.com/users?api-version=1.6 https://graph.windows.net/ {MYADB2C}.onmicrosoft.com/users?api-version=1.6

We have the provision via the Azure portal but could'nt find anything with REST API.我们通过 Azure 门户进行了配置,但找不到任何与 REST API 相关的内容。

UPDATED Sample request for Batch processing更新的批处理请求示例

POST https://graph.windows.net/{}.onmicrosoft.com/$batch?api-version=1.6
Headers :
Authorization : {token}
Content-Type : multipart/mixed; boundary=changeset_***********

Body :
{
  "requests": [
    {
      "id": "1",
      "method": "POST",
      "url": "/users",
      "body": {
        "accountEnabled": true,
        "creationType": "LocalAccount",
        "displayName": "test1@gamil.com",
        "passwordPolicies": "DisablePasswordExpiration, DisableStrongPassword",
        "passwordProfile": {
          "password": "***",
          "forceChangePasswordNextLogin": false
        },
        "signInNames": [
          {
            "type": "emailAddress",
            "value": "test1@gamil.com"
          }
        ]
      },
      "headers": {
        "Content-Type": "application/json"
      }
    },
    {
      "id": "2",
      "method": "POST",
      "url": "/users",
      "body": {
        "accountEnabled": true,
        "creationType": "LocalAccount",
        "displayName": "test2@gmail.com",
        "passwordPolicies": "DisablePasswordExpiration, DisableStrongPassword",
        "passwordProfile": {
          "password": "***",
          "forceChangePasswordNextLogin": false
        },
        "signInNames": [
          {
            "type": "emailAddress",
            "value": "test1@gamil.com"
          }
        ]
      },
      "headers": {
        "Content-Type": "application/json"
      }
    }
  ]
}

Yes.是的。 You can batch operations by referring to Batch processing |您可以参考批处理 |批处理操作 Graph API concepts . 图 API 概念

But we recommend you use Microsoft Graph API JSON Batching instead of Azure AD Graph Batch processing because Azure AD Graph content is no longer updated.但我们建议您使用Microsoft Graph API JSON Batching而不是 Azure AD Graph Batch 处理,因为 Azure AD Graph 内容不再更新。

An example using Microsoft Graph API here:此处使用 Microsoft Graph API 的示例:

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

{
  "requests": [
    {
      "id": "1",
      "method": "POST",
      "url": "/users",
      "body": {
          "accountEnabled": true,
          "displayName": "at1",
          "mailNickname": "at1",
          "userPrincipalName": "at1@**.onmicrosoft.com",
          "passwordProfile" : {
              "forceChangePasswordNextSignIn": true,
              "password": "password-value"
          }
      },
      "headers": {
        "Content-Type": "application/json"
      }
    },
    {
      "id": "2",
      "method": "POST",
      "url": "/users",
      "body": {
          "accountEnabled": true,
          "displayName": "at2",
          "mailNickname": "at2",
          "userPrincipalName": "at2@**.onmicrosoft.com",
          "passwordProfile" : {
              "forceChangePasswordNextSignIn": true,
              "password": "password-value"
          }
      },
      "headers": {
        "Content-Type": "application/json"
      }
    },
    {
      "id": "3",
      "method": "POST",
      "url": "/users",
      "body": {
          "accountEnabled": true,
          "displayName": "at3",
          "mailNickname": "at3",
          "userPrincipalName": "at3@**.onmicrosoft.com",
          "passwordProfile" : {
              "forceChangePasswordNextSignIn": true,
              "password": "password-value"
          }
      },
      "headers": {
        "Content-Type": "application/json"
      }
    }
  ]
}

You can have a quick test in Microsoft Graph Explorer .您可以在Microsoft Graph Explorer 中进行快速测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM