自动创建Azure AD B2C租户

时间:2015-10-27 09:42:08

标签: azure-active-directory

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

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

2 个答案:

答案 0 :(得分:2)

我担心目前您无法使用API​​或使用PowerShell创建Azure AD。虽然您可以在订阅中创建其他目录,但无法使用任何自动化创建一个目录。

答案 1 :(得分:0)

您可以使用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
相关问题