自动创建Azure AD B2C租户

8

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

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

2个回答

2

很抱歉,目前您无法使用API或PowerShell创建Azure AD。虽然您可以在订阅中创建其他目录,但无法使用任何自动化程序创建一个目录。


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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接