@@ -7,7 +7,7 @@ ms.service: virtual-machines
7
7
ms.topic : article
8
8
ms.tgt_pltfrm : vm-windows
9
9
ms.workload : infrastructure-services
10
- ms.date : 01/24 /2020
10
+ ms.date : 01/27 /2020
11
11
ms.author : cynthn
12
12
# pmcontact: zivr
13
13
---
@@ -66,25 +66,103 @@ Get-AzProximityPlacementGroup -ResourceId $ppg.Id |
66
66
Format-Table -Property VirtualMachines -Wrap
67
67
```
68
68
69
- ## Existing VM
69
+ ## Move an existing VM into a proximity placement group
70
70
71
71
You can also add an existing VM to a proximity placement group. You need to stop\deallocate the VM first, then update the VM and restart.
72
72
73
73
``` azurepowershell-interactive
74
- Stop-AzVM -Name myVM -ResourceGroupName myResourceGroup
75
74
$ppg = Get-AzProximityPlacementGroup -ResourceGroupName myPPGResourceGroup -Name myPPG
76
75
$vm = Get-AzVM -ResourceGroupName myResourceGroup -Name myVM
76
+ Stop-AzVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName
77
77
Update-AzVM -VM $vm -ResourceGroupName $vm.ResourceGroupName -ProximityPlacementGroupId $ppg.Id
78
- Restart-AzVM -Name myVM -ResourceGroupName myResourceGroup
78
+ Restart-AzVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName
79
79
```
80
80
81
+ ## Move an existing VM out of a proximity placement group
82
+
83
+ To remove a VM from a proximity placement group, you need to stop\deallocate the VM first, then update the VM and restart.
84
+
85
+ ``` azurepowershell-interactive
86
+ $ppg = Get-AzProximityPlacementGroup -ResourceGroupName myPPGResourceGroup -Name myPPG
87
+ $vm = Get-AzVM -ResourceGroupName myResourceGroup -Name myVM
88
+ Stop-AzVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName
89
+ $vm.ProximityPlacementGroupId = ""
90
+ Update-AzVM -VM $vm -ResourceGroupName $vm.ResourceGroupName
91
+ Restart-AzVM -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName
92
+ ```
93
+
94
+
81
95
## Availability Sets
82
96
You can also create an availability set in your proximity placement group. Use the same ` -ProximityPlacementGroup ` parameter with the [ New-AzAvailabilitySet] ( /powershell/module/az.compute/new-azavailabilityset ) cmdlet to create an availability set and all of the VMs created in the availability set will also be created in the same proximity placement group.
83
97
98
+ To add or remove an existing availability set to a proximity placement group, you first need to stop all of the VMs in the availability set.
99
+
100
+ ### Move an existing availability set into a proximity placement group
101
+
102
+ ``` azurepowershell-interactive
103
+ $resourceGroup = "myResourceGroup"
104
+ $avSetName = "myAvailabilitySet"
105
+ $avSet = Get-AzAvailabilitySet -ResourceGroupName $resourceGroup -Name $avSetName
106
+ $vmIds = $avSet.VirtualMachinesReferences
107
+ foreach ($vmId in $vmIDs){
108
+ $string = $vmID.Id.Split("/")
109
+ $vmName = $string[8]
110
+ Stop-AzVM -ResourceGroupName $resourceGroup -Name $vmName -Force
111
+ }
112
+
113
+ $ppg = Get-AzProximityPlacementGroup -ResourceGroupName myPPG -Name myPPG
114
+ Update-AzAvailabilitySet -AvailabilitySet $avSet -ProximityPlacementGroupId $ppg.Id
115
+ foreach ($vmId in $vmIDs){
116
+ $string = $vmID.Id.Split("/")
117
+ $vmName = $string[8]
118
+ Start-AzVM -ResourceGroupName $resourceGroup -Name $vmName
119
+ }
120
+ ```
121
+
122
+ ### Move an existing availability set out of a proximity placement group
123
+ ``` azurepowershell-interactive
124
+ $resourceGroup = "myResourceGroup"
125
+ $avSetName = "myAvailabilitySet"
126
+ $avSet = Get-AzAvailabilitySet -ResourceGroupName $resourceGroup -Name $avSetName
127
+ $vmIds = $avSet.VirtualMachinesReferences
128
+ foreach ($vmId in $vmIDs){
129
+ $string = $vmID.Id.Split("/")
130
+ $vmName = $string[8]
131
+ Stop-AzVM -ResourceGroupName $resourceGroup -Name $vmName -Force
132
+ }
133
+
134
+ $avSet.ProximityPlacementGroup = ""
135
+ Update-AzAvailabilitySet -AvailabilitySet $avSet
136
+ foreach ($vmId in $vmIDs){
137
+ $string = $vmID.Id.Split("/")
138
+ $vmName = $string[8]
139
+ Start-AzVM -ResourceGroupName $resourceGroup -Name $vmName
140
+ }
141
+ ```
142
+
84
143
## Scale sets
85
144
86
145
You can also create a scale set in your proximity placement group. Use the same ` -ProximityPlacementGroup ` parameter with [ New-AzVmss] ( https://docs.microsoft.com/powershell/module/az.compute/new-azvmss ) to create a scale set and all of the instances will be created in the same proximity placement group.
87
146
147
+
148
+ To add or remove an existing scale set to a proximity placement group, you first need to stop the scale set.
149
+
150
+ ### Move an existing scale set into a proximity placement group
151
+
152
+ $ppg = Get-AzProximityPlacementGroup -ResourceGroupName myPPG -Name myPPG
153
+ $vmss = Get-AzVmss -ResourceGroupName myVMSSResourceGroup -VMScaleSetName myScaleSet
154
+ Stop-AzVmss -VMScaleSetName $vmss.Name -ResourceGroupName $vmss.ResourceGroupName
155
+ Update-AzVmss -VMScaleSetName $vmss.Name -ResourceGroupName $vmss.ResourceGroupName -ProximityPlacementGroupId $ppg.Id
156
+ Restart-AzVmss -VMScaleSetName $vmss.Name -ResourceGroupName $vmss.ResourceGroupName
157
+
158
+ ### Move an existing scale set out of a proximity placement group
159
+
160
+ $vmss = Get-AzVmss -ResourceGroupName myVMSSResourceGroup -VMScaleSetName myScaleSet
161
+ Stop-AzVmss -VMScaleSetName $vmss.Name -ResourceGroupName $vmss.ResourceGroupName
162
+ $vmss.ProximityPlacementGroup = ""
163
+ Update-AzVmss -VirtualMachineScaleSet $vmss -VMScaleSetName $vmss.Name -ResourceGroupName $vmss.ResourceGroupName
164
+ Restart-AzVmss -VMScaleSetName $vmss.Name -ResourceGroupName $vmss.ResourceGroupName
165
+
88
166
## Next steps
89
167
90
168
You can also use the [ Azure CLI] ( ../linux/proximity-placement-groups.md ) to create proximity placement groups.
0 commit comments