【问题标题】:Automate creation of Azure AD B2C Tenants自动创建 Azure AD B2C 租户
【发布时间】:2016-01-26 15:44:07
【问题描述】:

是否可以以编程方式创建 Azure AD B2C 租户(例如,使用 Powershell、REST API)?

我们正在开发一个多租户 SaaS 解决方案,我们希望在新租户注册时自动为其创建 Azure B2C 租户。

【问题讨论】:

    标签: azure-active-directory azure-ad-b2c


    【解决方案1】:

    您可以使用 PowerShell AzureADPreview 2.0 模块来管理自定义策略、应用程序等。虽然不像 ARM 模板那么完整,但您现在可以自动化很多事情。

    完整文档在这里:AzureADPreview 2 docs

    我没有成功将此模块安装到 “旧” PowerShell (5.x),所以我试了一下“新”PowerShell 7 (Core)。 PowerShell 7 和 AzureAD 模块的唯一问题是 Connect-AzureAD 使用 .NET Core 中没有的加密函数,因此您必须使用 -UseWindowsPowerShell 选项导入 AzureADPreview 模块。

    这是一个示例,适用于 PowerShell 7:

    Install-Module AzureADPreview
    Import-Module AzureADPreview -UseWindowsPowerShell
    $tenantId = "yourb2ctenant.onmicrosoft.com"
    
    # Note: this will interactively ask your credentials. 
    #       If you want to run this unattended, use the -Credential parameter with a PSCredential object with a SecureString
    Connect-AzureAD -TenantId $tenantId
    
    # ready to go 
    
    #list your all custom policies:
    Get-AzureADMSTrustFrameworkPolicy
    
    # upload a policy:
    $policyId = "B2C_1A_TrustFrameworkBase"
    $policyFileName "YourTrustFrameworkBase.xml"
    Set-AzureADMSTrustFrameworkPolicy -Id $policyId -InputFilePath $policyFileName
    
    #list your all apps    
    Get-AzureADApplication 
    
    # examine one of you app and get ideas 
    $application = Get-AzureADApplication -ObjectId af46a788-8e55-4301-b2df-xxxxxxxxx 
    
    # create an application
    $applicationName = "yourappname"
    $application = New-AzureADApplication -DisplayName $applicationName -PublicClient $true etc
    

    【讨论】:

      【解决方案2】:

      恐怕目前您无法使用 API 或 PowerShell 创建 Azure AD。尽管您可以在订阅中创建其他目录,但您无法使用任何自动化方式创建目录。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-08
        • 2020-08-26
        • 1970-01-01
        • 2022-06-27
        相关资源
        最近更新 更多