是否可以通过编程方式创建Azure AD B2C租户(例如,使用Powershell、REST API)?
我们正在开发一个多租户Azure解决方案,我们希望在新租户注册时自动创建一个SaaS B2C租户。
发布于 2016-03-24 22:33:40
我担心目前您不能使用API或PowerShell创建Azure AD。虽然您可以在订阅中创建其他目录,但不能使用任何自动化创建一个目录。
发布于 2020-04-18 15:31:39
您可以使用PowerShell AzureADPreview 2.0模块来管理自定义策略、应用程序等。虽然不像ARM模板那样完整,但您现在可以自动化许多事情。
完整的文档在这里:AzureADPreview 2 docs
我没有成功地将这个模块安装到“旧的” PowerShell (5.x)上,所以我尝试了一下“新的”PowerShell 7(核心)。PowerShell 7和AzureAD模块的唯一问题是Connect-AzureAD使用的加密函数不在.NET核心中,因此您必须使用-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 etchttps://stackoverflow.com/questions/33364439
复制相似问题