Azure Local – Failover cluster – Storage Space Direct – Reinstall node in cluster

Applies to: Azure Local 21H2, 22H2 (And 23H2 and newer if repair-node does not work) – Windows Server with failover cluster and Storage Space Direct (S2D)

I had a case where I needed to reinstall nodes in a cluster. It was hard for me to find all the pieces to the puzzle so I have written all the required steps and PowerShell commands to do the job.
Before this procedure, I drained the node, shut it down and reinstalled Windows OS on it.

# On any node in the cluster - remove the node that is down because it has been reinstalled
Remove-MocPhysicalNode -nodeName NAMEOFNODE # THIS IS ONLY NEEDED IN SOME CASES AND CAN BE SKIPPED IF IT FAILS
Remove-ClusterNode -Cluster NAMEOFCLUSTER -Name NAMEOFREINSTALLEDNODE

# MANUAL STEP
# Go to Azure Portal and find the Azure Arc object for the node (if Azure Local / Azure Stack HCI) and delete the object)

Install-WindowsFeature -Name Hyper-V -IncludeManagementTools

Install-WindowsFeature -Name Failover-Clustering -IncludeAllSubFeature -IncludeManagementTools
Install-WindowsFeature -Name Storage-Replica -IncludeManagementTools
Install-WindowsFeature FS-FileServer -IncludeManagementTools

Install-WindowsFeature FS-Data-Deduplication -IncludeManagementTools
Install-WindowsFeature BitLocker -IncludeManagementTools
Install-WindowsFeature Containers -IncludeManagementTools
Install-WindowsFeature Data-Center-Bridging -IncludeManagementTools
Install-WindowsFeature EnhancedStorage -IncludeManagementTools
Install-WindowsFeature System-Insights -IncludeManagementTools
Install-WindowsFeature FS-SMBBW -IncludeManagementTools

Install-Module MOC
Install-Module Az.StackHCI -Force -AllowClobber

# Now reboot after installing all roles and features
shutdown -r -f -t 00

# Now some fun with Networking. All commands below must be modified for your need. In my case I had VMSwitches for Storage,Management and Compute
Get-NetAdapter

# Rename nics for storage - if multiple, rename them all
Rename-NetAdapter -name "Slot3 Port 2" -NewName "storagenic"

# Create VMSwitch for storage
$VMSwitch = New-VMSwitch -Name "StorageSwitch" -NetAdapterName "storagenic" -EnableEmbeddedTeaming $true
Set-VMSwitchTeam -Name $VMSwitch.Name -LoadBalancingAlgorithm HyperVPort
Set-VMSwitchTeam -Name $VMSwitch.Name -TeamingMode SwitchIndependent

# Because we are running without NetworkATC, I set static IP on storage VMSwitch. Index refers to the index number of the created VMSwitch interface for the storage VMSwitch. Replace index with the number you get
Get-NetAdapter -Name "(vEthernet (StorageSwitch)"
New-NetIPAddress -InterfaceIndex 23 -IPAddress 192.168.2.12 -PrefixLength 24

# Now we are moving on to the compute VMSwitch config
Rename-NetAdapter -name "em1" -NewName "productionnic"

$VMSwitch = New-VMSwitch -Name "ComputeSwitch" -NetAdapterName "productionnic","em2","em3","em4" -EnableEmbeddedTeaming $true
Set-VMSwitchTeam -Name $VMSwitch.Name -LoadBalancingAlgorithm HyperVPort
Set-VMSwitchTeam -Name $VMSwitch.Name -TeamingMode SwitchIndependent

# and lastly, we do management VMSwitch config
Rename-NetAdapter -name "slot2 Port 3" -NewName "Management Physical 1"
Rename-NetAdapter -name "slot2 Port 4" -NewName "Management Physical 2"

$VMSwitch = New-VMSwitch -Name "Management" -NetAdapterName "Management Physical 1","Management Physical 2" -EnableEmbeddedTeaming $true
Set-VMSwitchTeam -Name $VMSwitch.Name -LoadBalancingAlgorithm HyperVPort
Set-VMSwitchTeam -Name $VMSwitch.Name -TeamingMode SwitchIndependent

# Lets set up static IP on management VMSwitch
Get-NetAdapter -name "vEthernet (Management)"

New-NetIpAddress -InterfaceIndex 39 -IpAddress 10.81.91.12 -PrefixLength 24 -DefaultGateway 10.81.91.1

# Setup DNS server addresses on management VMSwitch interface. Use Sconfig if these commands bugs
Set-DnsClientServerAddress -InterfaceAlias "vEthernet (Management)" -ResetServerAddresses
Set-DnsClientServerAddress -InterfaceAlias "vEthernet (Management)" -ServerAddresses (10.10.10.10,10.10.10.11)


# MANUAL STEP
# Now join the node to Active Directory using Sconfig. Reboot node. 

# On an existing node in the cluster
Add-ClusterNode -Cluster NAMEOFCLUSTER -Name NAMEOFREINSTALLEDNODE

# Run on the new reinstalled node to enable Azure Benefit. Only used for Azure Local / Azure Stack
Enable-AzStackHCIAttestation

# If we forgot to remove the Azure Arc object in Azure, we can do it now and then run this command on the new node:
Enable-AzureStackHCIArcIntegration

After completing all the configuration and having joined the reinstalled node to the cluster, I recommend waiting with any new reboot of the nodes before all storage jobs as completed. Even then Cluster Pool shows as healthy in failover cluster, do not be fooled by this status:

Get-StoageJob will reveal that running repair jobs is active:

Wait for those jobs to complete!

When all storage jobs have completed, it is time to test VM live migration and cluster shared volumes owner moves.

Comments

Leave a Reply

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