0
votes

My issue

Can't create a databricks from script. Always getting this error message:

Private and public subnets should be unique for the Virtual Network '/subscriptions/XXXX/resourceGroups/rgtest64/providers/Microsoft.Network/virtualNetworks/vnet64'. Public subnet name: 'privsub64', Private subnet name: | 'privsub64'

How to reproduce

Just running this script:

$location="westeurope"
$rg =  "rgtest64"
$vnet = "vnet64"

New-AzResourceGroup -name $rg -Location westeurope

$dlg = New-AzDelegation -Name dbrdl -ServiceName "Microsoft.Databricks/workspaces"
$rdpRule = New-AzNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" -Access Allow `
    -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix Internet `
    -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$networkSecurityGroup = New-AzNetworkSecurityGroup -ResourceGroupName $rg `
    -Location $location -Name nsg-test -SecurityRules $rdpRule

$privSubnet = New-AzVirtualNetworkSubnetConfig -Name privsub64 -AddressPrefix "10.0.1.0/24" `
    -NetworkSecurityGroup $networkSecurityGroup -Delegation $dlg
$pubSubnet = New-AzVirtualNetworkSubnetConfig -Name pubsub64  -AddressPrefix "10.0.2.0/24" `
    -NetworkSecurityGroup $networkSecurityGroup -Delegation $dlg
$testVN = New-AzVirtualNetwork -Name $vnet -ResourceGroupName $rg `
    -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $privSubnet,$pubSubnet

New-AzDatabricksWorkspace -Name databricks-test-with-custom-vn -ResourceGroupName $rg -Location $location `
    -VirtualNetworkId $testVN.Id -PrivateSubnetName $privSubnet.Name -PublicSubnetName `
    $privSubnet.Name -Sku standard
  • PSVersion: 7.1.3
  • PSEdition: Core

What I tested

I tested the script on several subscriptions. I also tried without creating the subnets, same result. I tested from an ARM template, same result.

It is working if I don't reference any VNET, but for internal reasons I need to impose a specific VNET.

What I need

Understanding what happen, and what to do

Everything was working until a few days ago. I don't understand

thanks

1
According to the error, your public subnet and private subnet are the same. Please check it.Jim Xu

1 Answers

1
votes

According to the error, your public subnet,s name and your private subnet name are the same. Whew we deploy Databricks workspace into vnet, the two subnets should be different. Please update your script as

New-AzDatabricksWorkspace -Name databricks-test-with-custom-vn -ResourceGroupName $rg -Location $location `
    -VirtualNetworkId $testVN.Id -PrivateSubnetName $privSubnet.Name -PublicSubnetName `
    $pubSubnet.Name -Sku standard

.

The whole script is as below

$location="westeurope"
$rg =  "rgtest64"
$vnet = "vnet64"

New-AzResourceGroup -name $rg -Location westeurope

$dlg = New-AzDelegation -Name dbrdl -ServiceName "Microsoft.Databricks/workspaces"
$rdpRule = New-AzNetworkSecurityRuleConfig -Name rdp-rule -Description "Allow RDP" -Access Allow `
    -Protocol Tcp -Direction Inbound -Priority 100 -SourceAddressPrefix Internet `
    -SourcePortRange * -DestinationAddressPrefix * -DestinationPortRange 3389
$networkSecurityGroup = New-AzNetworkSecurityGroup -ResourceGroupName $rg `
    -Location $location -Name nsg-test -SecurityRules $rdpRule

$privSubnet = New-AzVirtualNetworkSubnetConfig -Name privsub64 -AddressPrefix "10.0.1.0/24" `
    -NetworkSecurityGroup $networkSecurityGroup -Delegation $dlg
$pubSubnet = New-AzVirtualNetworkSubnetConfig -Name pubsub64  -AddressPrefix "10.0.2.0/24" `
    -NetworkSecurityGroup $networkSecurityGroup -Delegation $dlg
$testVN = New-AzVirtualNetwork -Name $vnet -ResourceGroupName $rg `
    -Location $location -AddressPrefix "10.0.0.0/16" -Subnet $privSubnet,$pubSubnet

New-AzDatabricksWorkspace -Name databricks-test-with-custom-vn -ResourceGroupName $rg -Location $location `
    -VirtualNetworkId $testVN.Id -PrivateSubnetName $privSubnet.Name -PublicSubnetName `
    $pubSubnet.Name -Sku standard

enter image description here enter image description here