Getting error while provisioning managed domain using PowerShell

Copper Contributor

Hi All,

 

I am trying to provision Azure ADDS managed domain to prepare POC for my client. I used the same set of command earlier multiple times and didn't get any error. But today when I tried doing the same using PowerShell, I got below error

 

New-AzResource : BadRequest : The property 'ReplicaSets' is missing.
CorrelationId: 7588b953-9e72-4c23-8d20-a0a632928778
At line:1 char:1
+ New-AzResource -ResourceId "/subscriptions/$AzureSubscriptionId/resou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzResource], ErrorResponseMessageException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceCmdlet

 

I am following Microsoft Document and my command is as below

 

$AzureSubscriptionId = "MY_AZURE_SUBSCRIPTION_ID"
$ManagedDomainName = "My Domain"

# Enable Azure AD Domain Services for the directory.
New-AzResource -ResourceId "/subscriptions/$AzureSubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.AAD/DomainServices/$ManagedDomainName" `
-Location $AzureLocation `
-Properties @{"DomainName"=$ManagedDomainName; `
"SubnetId"="/subscriptions/$AzureSubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Network/virtualNetworks/$VnetName/subnets/DomainServices"} `
-Force -Verbose

 

I get same error when I try from Azure PowerShell prompt as well.

Any help in this regard is helpful.

7 Replies
Hello there,
did you try to provision the ADDS domain services from the portal?

Regards,
Allow me to add, can you share the full set of commands that you have ran, before the ones that you have shared? did you confirm the dedicated subnet creation to host the ADDS domain services?

Thank you,
Charbel HANNA

@Charbelhanna 

Thank you for your reply. I can provision from console but cannot do so using PowerShell from my system and PowerShell prompt of console. I have created dedicated subnets as well. Here is full script that I am trying.

Connect to Azure AD

Create Group, user and add user to group

Register-AzResourceProvider -ProviderNamespace Microsoft.AAD

$ResourceGroupName = "abhayadadds"
$AzureLocation = "eastus"

# Create the resource group.
New-AzResourceGroup `
-Name $ResourceGroupName `
-Location $AzureLocation

$VnetName = "abhayVnet"

# Create the dedicated subnet for AAD Domain Services.
$AaddsSubnet = New-AzVirtualNetworkSubnetConfig `
-Name DomainServices `
-AddressPrefix 10.0.0.0/24

$WorkloadSubnet = New-AzVirtualNetworkSubnetConfig `
-Name Workloads `
-AddressPrefix 10.0.1.0/24

# Create the virtual network in which you will enable Azure AD Domain Services.
$Vnet= New-AzVirtualNetwork `
-ResourceGroupName $ResourceGroupName `
-Location $AzureLocation `
-Name $VnetName `
-AddressPrefix 10.0.0.0/16 `
-Subnet $AaddsSubnet,$WorkloadSubnet


$AzureSubscriptionId = "My Subscription ID"
$ManagedDomainName = "Managed domain name"

# Enable Azure AD Domain Services for the directory.
New-AzResource -ResourceId "/subscriptions/$AzureSubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.AAD/DomainServices/$ManagedDomainName" `
-Location $AzureLocation `
-Properties @{"DomainName"=$ManagedDomainName; `
"SubnetId"="/subscriptions/$AzureSubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Network/virtualNetworks/$VnetName/subnets/DomainServices"} `
-Force -Verbose

@Abhay Pujari 

Hi, I have the same problem. My deployment script was running perfectly one month ago and now runs into this error.

 

New-AzResource : BadRequest : The property 'ReplicaSets' is missing.

 

It seems like a bug that made the property ReplicaSets mandatory.

@Abhay PujariSame issue here, on any tenant. I posted the bug report: https://github.com/MicrosoftDocs/azure-docs/issues/63558

 

I am going to try going with a JSON template and see if that fixes it. Documentation says ReplicaSets is non mandatory and it was added in 2020 as optional but its kicking back as missing from the list of properties.

@Abhay PujariThe fix is to specify the ApiVersion when you kick off New-AzResource... the code would be:

 

New-AzResource -ResourceId "/subscriptions/$AzureSubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.AAD/DomainServices/$ManagedDomainName" `
-Location $AzureLocation `
-Properties @{"DomainName"=$ManagedDomainName; `
"SubnetId"="/subscriptions/$AzureSubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Network/virtualNetworks/$VnetName/subnets/DomainServices"} ` -ApiVersion "2017-06-01" -Force -Verbose