-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUpdateVMSSwithNewNAT.ps1
19 lines (15 loc) · 1.16 KB
/
UpdateVMSSwithNewNAT.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#Parameter
$resourceGroupName = "<TargetRG>"
$vmssName = "<TargetVMSS>"
$newinboundnatpool = "/subscriptions/xxxx/resourceGroups/xxxxx/providers/Microsoft.Network/loadBalancers/xxxxx/inboundNatPools/xxxxxxxxx"
#Update VMSS Network Config
$targetVmss = Get-AzureRmVmss -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssName
$oldConfig = $targetVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0]
$newvmssipconfig = New-AzureRmVmssIpConfig -Name $oldConfig.Name`
-LoadBalancerBackendAddressPoolsId $oldConfig.LoadBalancerBackendAddressPools[0].Id `
-LoadBalancerInboundNatPoolsId @($oldConfig.LoadBalancerInboundNatPools[0].Id, $newinboundnatpool) `
-SubnetId $oldConfig.Subnet.Id
$targetVmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0] = $newvmssipconfig
Update-AzureRmVmss -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssName -VirtualMachineScaleSet $targetVmss
#Manual Upgrade for each instances
Get-AzureRmVmssVM -ResourceGroupName $resourceGroupName -Name $vmssName | Update-AzureRmVmssInstance -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssName