I can do it in the Azure Portal by browsing to the backend pool of the load balancer and associate my VMSS, but I need to automate it with Azure PowerShell.
This is what I have so far but I can not save the updated network settings.
$vmss = Get-AzVmss -VMScaleSetName myVMs
$lb = Get-AzLoadBalancer -Name lb-internal;
$vmss.VirtualMachineProfile.NetworkProfile.
NetworkInterfaceConfigurations.IpConfigurations.
LoadBalancerBackendAddressPools.Add($lb.BackendAddressPools[0].Id)
Is this how it is supposed to be done, if so, how do I save or update the VMSS network settings?
I think you had the right idea, unfortunately it isn't as simple as that from looking at the documentation. The following should get you to where you need to be (the scale set has to be powered off for the update command to work I believe):
$myVmss = Get-AzVmss -ResourceGroupName myRg -Name myVmss
$ipConfig = New-AzVmssIpConfig `
-Name myNewConfig `
-SubnetId $mySubnetId ` # replace with id of subnet
-LoadBalancerBackendAddressPoolsId $backendPoolId # replace with id of backend pool
Add-AzVmssNetworkInterfaceConfiguration `
-Name myNewConfig `
-Primary $true `
-IpConfiguration $ipConfig `
-VirtualMachineScaleSet $myVmss `
$myVmss | Update-AzVmss