在 Azure Active Directory 中批量创建用户Bulk create users in Azure Active Directory

Azure Active Directory (Azure AD) 支持批量用户创建和删除操作,并支持下载用户列表。Azure Active Directory (Azure AD) supports bulk user create and delete operations and supports downloading lists of users. 只需填写可从 Azure AD 门户下载的逗号分隔值 (CSV) 模板即可。Just fill out comma-separated values (CSV) template you can download from the Azure AD portal.

所需的权限Required permissions

若要在管理门户中批量创建用户,你必须以全局管理员或用户管理员身份登录。In order to bulk create users in the administration portal, you must be signed in as a Global administrator or User administrator.

了解 CSV 模板Understand the CSV template

下载并填写批量上传 CSV 模板,帮助你成功批量创建 Azure AD 用户。Download and fill in the bulk upload CSV template to help you successfully create Azure AD users in bulk. 下载的 CSV 模板可能如下例所示:The CSV template you download might look like this example:

用于上传和调出的电子表格,说明了每一行和每一列的用途和值

警告

如果要使用 CSV 模板仅添加一个条目,则必须保留第 3 行并将新条目添加到第 4 行。If you are adding only one entry using the CSV template, you must preserve row 3 and add your new entry to row 4.

CSV 模板结构CSV template structure

下载的 CSV 模板中的行如下所示:The rows in a downloaded CSV template are as follows:

  • 版本号 :包含版本号的第一行必须包含在上传的 CSV 中。Version number : The first row containing the version number must be included in the upload CSV.
  • 列标题:列标题的格式为:<项名称> [PropertyName] <必需或空白>。Column headings : The format of the column headings is <Item name> [PropertyName] <Required or blank>. 例如,Name [displayName] RequiredFor example, Name [displayName] Required. 某些较旧版本的模板可能会略有不同。Some older versions of the template might have slight variations.
  • 示例行:我们已经在模板中包含了一行示例,说明每列可接受的值。Examples row : We have included in the template a row of examples of acceptable values for each column. 必须删除示例行并将其替换为你自己的项。You must remove the examples row and replace it with your own entries.

其他指南Additional guidance

  • 不得删除或修改上传模板的前两行,否则无法处理上传。The first two rows of the upload template must not be removed or modified, or the upload can't be processed.
  • 所需的列会先列出。The required columns are listed first.
  • 建议不要将新列添加到模板。We don't recommend adding new columns to the template. 所添加的任何其他列都会被忽略,不进行处理。Any additional columns you add are ignored and not processed.
  • 建议尽可能经常下载 CSV 模板的最新版本。We recommend that you download the latest version of the CSV template as often as possible.
  • 请确保检查任何字段前面/后面没有任何意外的空格。Make sure to check there is no unintended whitespace before/after any field. 对于“用户主体名称”,存在此类空格会导致导入失败。For User principal name , having such whitespace would cause import failure.

批量创建用户To create users in bulk

  1. 使用组织中的用户管理员帐户登录到 Azure AD 组织Sign in to your Azure AD organization with an account that is a User administrator in the organization.

  2. 在 Azure AD 中,选择“用户” > “批量创建”。In Azure AD, select Users > Bulk create.

  3. 在“批量创建用户”页上,选择“下载”,以接收用户属性的有效逗号分隔值 (CSV) 文件,然后添加要创建的用户。On the Bulk create user page, select Download to receive a valid comma-separated values (CSV) file of user properties, and then add add users you want to create.

    选择要在其中列出你要添加的用户的本地 CSV 文件

  4. 打开 CSV 文件,并为每个要创建的用户添加一行。Open the CSV file and add a line for each user you want to create. 只有“名称”、“用户主体名称”、“初始密码”和“阻止登录(是/否)”为必填项。The only required values are Name , User principal name , Initial password and Block sign in (Yes/No). 然后保存文件。Then save the file.

    CSV 文件包含要创建的用户姓名和 IDThe CSV file contains names and IDs of the users to create

  5. 在“批量创建用户”页中,在“上传 CSV 文件”下,浏览到该文件。On the Bulk create user page, under Upload your CSV file, browse to the file. 选择该文件并单击“提交”后,将启动对 CSV 文件的验证。When you select the file and click Submit , validation of the CSV file starts.

  6. 验证文件内容后,会看到“文件上传成功”的消息。After the file contents are validated, you’ll see File uploaded successfully. 如果有错误,必须修正错误,然后才能提交作业。If there are errors, you must fix them before you can submit the job.

  7. 文件通过验证后,请选择“提交”,以启动导入新用户的 Azure 批量操作。When your file passes validation, select Submit to start the Azure bulk operation that imports the new users.

  8. 导入操作完成后,会显示一条通知,指示批量操作作业状态。When the import operation completes, you'll see a notification of the bulk operation job status.

如果有错误,可以在“批量操作结果”页下载并查看结果文件。If there are errors, you can download and view the results file on the Bulk operation results page. 该文件包含每个错误的原因。The file contains the reason for each error. 文件提交必须与提供的模板匹配,并包含确切的列名称。The file submission must match the provided template and include the exact column names.

查看状态Check status

可在“批量操作结果”页中查看所有挂起的批量请求的状态。You can see the status of all of your pending bulk requests in the Bulk operation results page.

在“批量操作结果”页中查看创建状态Check create status in the Bulk Operations Results page

接下来,可在 Azure 门户中或使用 PowerShell 查看已创建的用户是否存在于 Azure AD 组织中。Next, you can check to see that the users you created exist in the Azure AD organization either in the Azure portal or by using PowerShell.

在 Azure 门户中验证用户Verify users in the Azure portal

  1. 使用组织中的用户管理员帐户登录到 Azure AD 管理中心Sign in to the Azure AD admin center with an account that is a User administrator in the organization.
  2. 在导航窗格中选择“Azure Active Directory”。In the navigation pane, select Azure Active Directory.
  3. 在“管理”下,选择“用户” 。Under Manage , select Users.
  4. 在“显示”下选择“所有用户”,并验证创建的用户是否已列出。Under Show , select All users and verify that the users you created are listed.

使用 PowerShell 验证用户Verify users with PowerShell

运行以下命令:Run the following command:

Get-AzureADUser -Filter "UserType eq 'Member'"

应会看到你创建的用户已列出。You should see that the users that you created are listed.

“批量导入”服务限制Bulk import service limits

创建用户的每个批量活动最多可运行一小时。Each bulk activity to create users can run for up to one hour. 这样就可以批量创建至少 50,000 个用户。This enables bulk creation of at least 50,000 users.

后续步骤Next steps