快速入门:设置开发环境Quickstart: Set up a dev environment

Microsoft 标识平台可让开发人员生成面向各种自定义 Microsoft 365 环境和标识的应用程序。The Microsoft identity platform allows developers to build apps targeting a wide variety of custom Microsoft 365 environments and identities. 要开始使用 Microsoft 标识平台,你将需要访问环境(也称为 Azure AD 租户),该环境可以注册和管理应用、可以访问 Microsoft 365 数据并部署租户限制。To get started using Microsoft identity platform, you will need access to an environment, also called an Azure AD tenant, that can register and manage apps, have access to Microsoft 365 data, and deploy tenant restrictions.

租户是组织的表示形式。A tenant is a representation of an organization. 它是 Azure AD 专用实例,组织或应用开发人员与 Microsoft 建立关系时(例如注册 Azure、Microsoft Intune 或 Microsoft 365)会收到该实例。It's a dedicated instance of Azure AD that an organization or app developer receives when the organization or app developer creates a relationship with Microsoft-- like signing up for Azure, Microsoft Intune, or Microsoft 365.

每个 Azure AD 租户都与其他 Azure AD 租户不同并单独存在,而且使用自己的工作和学校标识、消费者标识(如果是 Azure AD B2C 租户)以及应用注册进行表示。Each Azure AD tenant is distinct and separate from other Azure AD tenants and has its own representation of work and school identities, consumer identities (if it's an Azure AD B2C tenant), and app registrations. 租户内部的应用注册只允许从租户或所有租户的帐户中进行身份验证。An app registration inside of your tenant can allow authentications from accounts only within your tenant or all tenants.

确定环境类型Determining environment type

有两种可以创建的环境类型。There are two types of environments you can create. 确定所需的内容仅基于你的应用将进行身份验证的用户类型。Deciding which you need is based solely on the types of users your app will authenticate.

  • 工作和学校(Azure AD 帐户)Work and school (Azure AD accounts)
  • 社交和本地帐户(Azure AD B2C)Social and local accounts (Azure AD B2C)

本快速入门分为两种方案,具体取决于所要生成的应用类型。The quickstart is broken into two scenarios depending on the type of app you want to build. 如需获取更多针对标识类型的帮助,请参阅关于 Microsoft 标识平台If you need more help targeting an identity type, take a look at about Microsoft identity platform

工作和学校帐户Work and school accounts

使用现有租户Use an existing tenant

许多开发人员已通过绑定到 Azure AD 租户的服务或订阅(例如 Microsoft 365 或 Azure 订阅)获得了租户。Many developers already have tenants through services or subscriptions that are tied to Azure AD tenants such as Microsoft 365 or Azure subscriptions.

  1. 要检查租户,请使用要用于管理应用程序的帐户登录 Azure 门户To check the tenant, sign in to the Azure portal with the account you want to use to manage your application.
  2. 查看右上角。Check the upper right corner. 如果你有一个租户,则会自动登录到该租户,并且帐户名的正下方会显示租户名称。If you have a tenant, you'll automatically be logged in and can see the tenant name directly under your account name.
    • 将鼠标指针悬停在 Azure 门户右上角的帐户名上,可以查看你的姓名、电子邮件、目录和租户 ID (GUID) 以及域。Hover over your account name on the upper right-hand side of the Azure portal to see your name, email, directory / tenant ID (a GUID), and your domain.
    • 如果帐户与多个租户相关联,则可以选择帐户名打开一个菜单,并在其中切换租户。If your account is associated with multiple tenants, you can select your account name to open a menu where you can switch between tenants. 每个租户都有自己的唯一租户 ID。Each tenant has its own tenant ID.

Tip

如果需要查找租户 ID,可执行以下操作:If you need to find the tenant ID, you can:

  • 将鼠标指针悬停在帐户名上以获取目录/租户 ID,或Hover over your account name to get the directory / tenant ID, or
  • 在 Azure 门户中选择“Azure Active Directory”>“属性”>“目录 ID” Select Azure Active Directory > Properties > Directory ID in the Azure portal

如果没有任何与帐户关联的现有租户,则帐户名下面会显示一个 GUID;另外,除非按照下一节的步骤操作,否则无法执行注册应用等操作。If you don't have an existing tenant associated with your account, you'll see a GUID under your account name and you won't be able to perform actions like registering apps until you follow the steps of the next section.

创建新的 Azure AD 租户Create a new Azure AD tenant

如果还没有 Azure AD 租户或想要为开发创建新租户,请遵循目录创建体验If you don't already have an Azure AD tenant or want to create a new one for development, follow the directory creation experience. 必须提供以下信息才能创建新租户:You will have to provide the following info to create your new tenant:

  • 组织名称Organization name
  • 初始域 - 这将是 *.partner.onmschina.cn 的一部分。Initial domain - this will be part of *.partner.onmschina.cn. 稍后你可以更详细地自定义域。You can customize the domain more later.
  • 国家或地区Country or region

Note

对租户进行命名时,请使用字母数字字符。When naming your tenant, use alphanumeric characters. 不允许使用特殊字符。Special characters are not allowed. 名称不得超过 256 个字符。The name must not exceed 256 characters.

社交和本地帐户Social and local accounts

要开始生成登录社交和本地帐户的应用,你将需要创建 Azure AD B2C 租户。To begin building apps that sign in social and local accounts, you'll need to create an Azure AD B2C tenant. 请从创建 Azure AD B2C 租户开始。To begin, follow creating an Azure AD B2C tenant.

后续步骤Next steps

  • 尝试编写快速入门代码并开始对用户进行身份验证。Try a coding quickstart and begin authenticating users.
  • 有关更多深入的代码示例,请参阅文档的“教程”部分 。For more in-depth code samples, check out the Tutorials section of the documentation.