You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何以编程方式创建Azure AD B2C租户、应用及用户流?

Azure AD B2C 资源自动化创建方案

当然可以通过编程方式自动化创建Azure AD B2C的租户、应用程序、用户流等资源,以下是常用的实现方式:

1. 创建Azure AD B2C租户

可以通过Azure CLI或REST API完成租户创建:

  • Azure CLI示例:
    az ad b2c tenant create --name "your-b2c-tenant-name.onmicrosoft.com" --location "your-region" --sku "PremiumP2"
    
    参数说明:name为租户的域名前缀,location选择支持B2C的区域(如eastus),sku可选PremiumP1或PremiumP2。

2. 注册应用程序

使用Azure CLI或Microsoft Graph API创建和配置B2C应用:

  • Azure CLI示例(创建Web应用):
    az ad app create --display-name "B2C-Web-App" --web-redirect-uris "https://yourapp.com/callback" --enable-id-token-issuance true --sign-in-audience "AzureADandPersonalMicrosoftAccount"
    
    后续可通过az ad app credential reset生成应用密钥,az ad app permission grant配置所需权限。

3. 创建用户流

用户流的自动化可通过Azure CLI或Microsoft Graph API实现:

  • Azure CLI示例(创建注册/登录流):
    az ad b2c user-flow create --name "B2C_1_signupsignin" --type "signupsignin" --tenant "your-b2c-tenant-name.onmicrosoft.com"
    
  • Microsoft Graph API示例(POST请求):
    POST https://graph.microsoft.com/v1.0/identity/b2cUserFlows
    Content-Type: application/json
    
    {
      "id": "B2C_1_signupsignin",
      "userFlowType": "signUpOrSignIn",
      "userFlowTypeVersion": 1,
      "identityProviders": [
        {
          "id": "MicrosoftAccounts-OIDC",
          "type": "OpenIdConnect"
        }
      ]
    }
    

4. 其他工具选项

  • PowerShell:使用Azure AD PowerShell模块或Microsoft Graph PowerShell模块,调用对应cmdlet完成资源创建。
  • 基础设施即代码(IaC):用Terraform的AzureRM provider或Azure Bicep编写模板,批量部署B2C租户及关联资源。

所有操作需确保执行账号拥有足够权限(如Azure AD全局管理员、B2C租户管理员)。

内容的提问来源于stack exchange,提问作者wonderful world

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 20:18:20