教程:批量邀请 Azure AD B2B 协作用户Tutorial: Bulk invite Azure AD B2B collaboration users

如果使用 Azure Active Directory (Azure AD) B2B 协作功能与外部合作伙伴进行协作,可同时邀请多名来宾用户加入你的组织。If you use Azure Active Directory (Azure AD) B2B collaboration to work with external partners, you can invite multiple guest users to your organization at the same time. 本教程介绍如何使用 Azure 门户向外部用户批量发送邀请。In this tutorial, you learn how to use the Azure portal to send bulk invitations to external users. 具体操作如下:Specifically, you do the following:

  • 使用“批量邀请用户”准备一个包含用户信息和邀请首选项的逗号分隔值 (.csv) 文件Use Bulk invite users to prepare a comma-separated value (.csv) file with the user information and invitation preferences
  • 将 .csv 文件上传到 Azure ADUpload the .csv file to Azure AD
  • 验证是否已将用户添加到目录中Verify the users were added to the directory

如果没有 Azure Active Directory,请在开始前创建一个试用版If you don’t have Azure Active Directory, create a Trial before you begin.

了解 CSV 模板Understand the CSV template

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

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

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>. 例如,Email address to invite [inviteeEmail] RequiredFor example, Email address to invite [inviteeEmail] 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.

先决条件Prerequisites

需要两个或更多可向其发送邀请的测试电子邮件帐户。You need two or more test email accounts that you can send the invitations to. 这些帐户必须来自组织外部。The accounts must be from outside your organization.

批量邀请来宾用户Invite guest users in bulk

  1. 使用组织中的用户管理员的帐户登录到 Azure 门户。Sign in to the Azure portal 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 > Bulk invite.

  4. 在“批量邀请用户”页上,选择“下载”以获取一个包含邀请属性的有效 .csv 模板。On the Bulk invite users page, select Download to get a valid .csv template with invitation properties.

    批量邀请的下载按钮

  5. 打开 .csv 模板,为每个来宾用户添加一行。Open the .csv template and add a line for each guest user. 必需的值为:Required values are:

    • 要邀请的电子邮件地址 - 会收到邀请的用户Email address to invite - the user who will receive an invitation

    • 重定向 url - 一个 URL,受邀请的用户在接受邀请后会被系统定向到该 URLRedirection url - the URL to which the invited user is forwarded after accepting the invitation

    CSV 文件的示例,其中已输入来宾用户

    备注

    请勿在自定义的邀请消息中使用逗号,因为这样会妨碍系统对消息成功进行分析。Don't use commas in the Customized invitation message because they'll prevent the message from being parsed successfully.

  6. 保存文件。Save the file.

  7. 在“批量邀请用户”页中,在“上传 csv 文件”下,浏览找到该文件。On the Bulk invite users page, under Upload your csv file, browse to the file. 选择该 .csv 文件后,对其的验证就会开始。When you select the file, validation of the .csv file starts.

  8. 验证文件内容后,会看到“文件上传成功”消息。When 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.

  9. 文件通过验证以后,请选择“提交”,开始用于添加邀请的 Azure 批量操作。When your file passes validation, select Submit to start the Azure bulk operation that adds the invitations.

  10. 若要查看作业状态,请选择“单击此处查看每项操作的状态”。To view the job status, select Click here to view the status of each operation. 也可在“活动”部分中选择“批量操作结果”。 Or, you can select Bulk operation results in the Activity section. 若要了解批量操作中每个行项的详细信息,请选择“成功数”、“失败数”或“请求总数”列下的值。 For details about each line item within the the bulk operation, select the values under the # Success, # Failure, or Total Requests columns. 如果失败,则会列出失败原因。If failures occurred, the reasons for failure will be listed.

    批量操作结果的示例

  11. 作业完成后,会显示一条通知,指出批量操作成功。When the job completes, you'll see a notification that the bulk operation succeeded.

验证目录中的来宾用户Verify guest users in the directory

通过 Azure 门户或 PowerShell 进行检查,看已添加的来宾用户是否存在于目录中。Check to see that the guest users you added exist in the directory either in the Azure portal or by using PowerShell.

在 Azure 门户中查看来宾用户View guest users in the Azure portal

  1. 使用组织中的用户管理员的帐户登录到 Azure 门户。Sign in to the Azure portal 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 Guest users only and verify the users you added are listed.

使用 PowerShell 查看来宾用户View guest users with PowerShell

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

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

应会看到已列出受邀用户,其中用户主体名称 (UPN) 采用 emailaddress#EXT#@domain 的格式。You should see the users that you invited listed, with a user principal name (UPN) in the format emailaddress#EXT#@domain. 例如,lstokes_fabrikam.com#EXT#@contoso.partner.onmschina.cn,其中 contoso.partner.onmschina.cn 是你从中发送邀请的组织。For example, lstokes_fabrikam.com#EXT#@contoso.partner.onmschina.cn, where contoso.partner.onmschina.cn is the organization from which you sent the invitations.

清理资源Clean up resources

不再需要目录中的测试用户帐户时,可在 Azure 门户的“用户”页上将其删除,方法是:选择来宾用户旁边的复选框,然后选择“删除”。When no longer needed, you can delete the test user accounts in the directory in the Azure portal on the Users page by selecting the checkbox next to the guest user and then selecting Delete.

也可运行以下 PowerShell 命令来删除用户帐户:Or you can run the following PowerShell command to delete a user account:

 Remove-AzureADUser -ObjectId "<UPN>"

例如: Remove-AzureADUser -ObjectId "lstokes_fabrikam.com#EXT#@contoso.partner.onmschina.cn"For example: Remove-AzureADUser -ObjectId "lstokes_fabrikam.com#EXT#@contoso.partner.onmschina.cn"

后续步骤Next steps

在本教程中,你向组织外部的来宾用户批量发送了邀请。In this tutorial, you sent bulk invitations to guest users outside of your organization. 接下来,将学习如何执行邀请兑换过程。Next, learn how the invitation redemption process works.