无法创建具有二头肌的azure b2c租户



我正在尝试创建一个有二头肌的azure B2c租户。当我在门户网站上做这件事时,一切都很好。有了地形也一切都好。但有了肱二头肌,我得到了这个

New-AzSubscriptionDeployment:5:41:21 PM-部署"xpto devTEST"失败,出现错误。显示2个错误中的2个。状态消息:资源的响应包含空内容或无效内容。(代码:ResourceDeploymentFailure(状态消息:至少有一个资源部署操作失败。有关详细信息,请列出部署操作。请参阅

  • {"错误":{"代码":"ResourceDeploymentFailure";,"消息":"资源的响应包含空内容或无效内容"}}(代码:InternalServerError(相关性ID:c0a20039-0a78-44c3-94fb-998c53c661a4行:1字符:1
  • 新建AzSubscriptionDeployment-名称xpto devTEST-模板
  • + CategoryInfo          : NotSpecified: (:) [New-AzDeployment], Exception
    + FullyQualifiedErrorId : >Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureSubscriptionDeploymentCmdlet
    

我的主要二头肌有这个

@description('the name of the environment. this must be dev, test, or prod.')
@allowed([
'dev'
'test'
'prod'
])
param environmentname string = 'dev'
@description('the location of the resource')
param location string = 'northeurope'
@description('Name of the resource group')
param resourceGroupName string = 'xpto-${environmentname}'
targetScope = 'subscription'
resource rg 'microsoft.resources/resourcegroups@2021-04-01' = {
name: resourceGroupName
location:location
}
module azureb2c 'modules/azureB2C.bicep' = {
name: 'xptoTenant-${environmentname}'
scope: rg
}

我的模块有这个

@description('The name of the environment. This must be dev, test, or prod.')
@allowed([
'dev'
'test'
'prod'
])
param environmentName string = 'dev'
@description('The location of the resource')
param location string = 'Europe'
resource b2c 'Microsoft.AzureActiveDirectory/b2cDirectories@2019-01-01-preview' ={
name: 'xpto${environmentName}Tenant.onmicrosoft.com'
location: location
sku: {
name: 'PremiumP1'
}
properties:{
createTenantProperties:{
displayName: 'xpto-${environmentName}-tenant'
countryCode: 'PT'

}
}
}

我运行的命令是这个

New-AzSubscriptionDeployment -Name xpto-devTEST -TemplateFile main.bicep -TemplateParameterFile .main.parameters-dev.json -DeploymentDebugLogLevel All

有人能帮我吗?

resource b2cDirectory 'Microsoft.AzureActiveDirectory/b2cDirectories@2021-04-01' = {
#disable-next-line no-hardcoded-location
location: 'Australia'
name: '<your-name>.onmicrosoft.com'
sku: {
name: 'PremiumP2'
tier: 'A0'
}
properties: {
createTenantProperties: {
countryCode: 'AU'
displayName: '<Your description>'
}
}
tags: {
Department: 'Dev'
}
}

工作!名称可能很重要,您需要使用有效的DNS名称来命名资源。

无法从任何IAC工具创建。由于Microsoft.AzureActiveDirectory/b2cDirectories@2019-01-01-previewRest API尚未添加到IAC modules

作为替代方案,您可以将Az CLIRest API's一起使用,并使用以下脚本:

az login
SUBS=`az account show --query "id" -o tsv` 
RG=b2cdemotest 
DOMAIN=b2cdemo1ansuman 
LOCATION=westeurope
az group create --name $RG --location $LOCATION

# deploy
az rest --method put --url https://management.azure.com/subscriptions/$SUBS/resourceGroups/$RG/providers/Microsoft.AzureActiveDirectory/b2cDirectories/$DOMAIN.onmicrosoft.com?api-version=2019-01-01-preview --body @b2c.json --verbose

# get
az account tenant list
az rest --method get --url https://management.azure.com/subscriptions/$SUBS/resourceGroups/$RG/providers/Microsoft.AzureActiveDirectory/b2cDirectories/$DOMAIN.onmicrosoft.com?api-version=2019-01-01-preview | jq

# delete
az rest --method delete --url https://management.azure.com/subscriptions/$SUBS/resourceGroups/$RG/providers/Microsoft.AzureActiveDirectory/b2cDirectories/$DOMAIN.onmicrosoft.com?api-version=2019-01-01-preview --verbose
> verify if B2C tenant was removed then remove the Resource Group
az group delete --name $RG

b2c.json file

{
"location":"europe",
"sku": {
"name":"Standard",
"tier":"A0"
},
"properties": {
"createTenantProperties": {
"displayName":"b2c-demo-ansuman",
"countryCode":"PL"
}
}
}

相关内容

  • 没有找到相关文章

最新更新