我想使用 terraform 创建一个 B2C 租户。并且需要在该租户中创建应用程序并创建用户并分配角色。我在主租户中使用 terraform 创建了一个 b2c 租户,但无法在其中创建应用程序和用户。
我已经从主租户创建了一个 b2c 租户,但不知道如何从主租户在 b2c 中创建应用程序和用户。如果没有,如何使用 terraform 直接在 B2C 租户中创建用户和应用程序。
B2c 租户使用 terraform 从主租户创建和创建用户/应用程序。
是的,可以从主租户创建租户和应用程序、用户。
我的地形配置:
# Configure Azure Provider
provider "azurerm" {
features {}
}
# Create Azure AD B2C Directory
resource "azurerm_aadb2c_directory" "example" {
country_code = "US"
data_residency_location = "United States"
display_name = "vksbtenant"
domain_name = "vkssbtenant.onmicrosoft.com"
resource_group_name = "vinay-rg"
sku_name = "PremiumP1"
}
output "tenant_id" {
value = azurerm_aadb2c_directory.example.tenant_id
}
# Configure Azure AD Provider (using the obtained tenant ID)
provider "azuread" {
tenant_id = azurerm_aadb2c_directory.example.tenant_id
}
# Create Azure AD B2C Application (dependent on AAD B2C Directory)
resource "azuread_application" "b2c_app" {
display_name = "MyB2CApplication"
depends_on = [azurerm_aadb2c_directory.example]
# Additional configurations as needed for your application
}
# Create Azure AD User (optional, dependent on AAD Provider)
resource "azuread_user" "example" {
# Use domain name from AAD B2C Directory
user_principal_name = "[email protected]"
display_name = "J. Doe"
mail_nickname = "jdoe"
password = "yourpassword"
depends_on = [ azurerm_aadb2c_directory.example ]
}
部署成功: