Azure Local – Recreate VM switch for Network ATC Intent

This article contains commands for recreating a VM switch with VM Switch Embedded Team for the Converged Switch for management and compute. This assumes that management and compute is combined in the same Network ATC Intent on your cluster. Normally this is not something you would do, but if you see issues or errors like I have seen on a Azure Local 23H2 cluster, knowing how to recreate the VM switch is crucial.

These are the input variables for the commands:

# Define name of the VM switch we are going to remove and recreate
$VMSwitchName = "ConvergedSwitch(compute_management)"
$IntentName = "compute_management"
#Define name of the NICs we are going to use for the converged switch
$NICS = 'pNic1,pNic2'
# Name of the Azure Stack Local cluster
$HCIClusterName = "cluazhci01"
# Name of the Azure Stack Local host - automatically retrieved from the environment variable COMPUTERNAME
$Hostname = Get-Content env:COMPUTERNAME
# IP address, prexix, default gateway and DNS for the converged switch
$IPAddress = "10.10.10.10"
$PrefixLength = 24
$DefaultGateway = "10.10.10.1"
$DNS1 = "10.0.0.10"
$DNS2 = "10.0.0.11"

Remove the VMSwitch (this will also recreate the switech embedded team):

Remove-VMSwitch -Name $VMSwitchName
Start-Sleep -Seconds 10

The Network Intent will not detect these changes, so you need to trigger the intent to re-run validation test and have Network ATC auto create the VM Switch again.

# This command requires a domain joined user to run
Set-NetIntentRetryState -ClusterName $HCIClusterName -Name $IntentName -NodeName $Hostname

The VM switch will take one of the IP addresses from the physical NICs. If you are not satisifed with the IP on the newly recreated VM switch for management of the node, you can remove IP configuration and reconfigure:

# Get-NetIPAddress -InterfaceAlias $VMSwitch.InterfaseAlias | Remove-NetIPAddress -Confirm:$false
# New-NetIPAddress -InterfaceAlias $VMSwitch.InterfaseAlias -IPAddress 1$IPAddress -PrefixLength $PrefixLength -DefaultGateway $DefaultGateway
# Set-DnsClientServerAddress -InterfaceAlias $VMSwitch.InterfaseAlias -ServerAddresses ($DNS1,$DNS2)

If Network ATC does not auto create the VM Switch after a few minutes (after you run the command Set-NetworkRetryState), you can manually create the VM switch:

$VMSwitch = New-VMSwitch -Name $VMSwitchName -NetAdapterName $NICS -EnableEmbeddedTeaming $true
Set-VMSwitchTeam -Name $VMSwitchName -LoadBalancingAlgorithm HyperVPortSet-VMSwitchTeam -Name $VMSwitchName -TeamingMode SwitchIndependent
Update-NetIntentAdapter -ComputerName $Hostname -Name $IntentName -AdapterName $NICS

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *