Skip to content

Commit c13d3fc

Browse files
author
Ankita Dutta
committed
CLI updates
1 parent f708ca5 commit c13d3fc

File tree

2 files changed

+121
-25
lines changed

2 files changed

+121
-25
lines changed

articles/virtual-machines/move-virtual-machines-regional-zonal-portal.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to move single instance Azure virtual machines from a reg
44
author: ankitaduttaMSFT
55
ms.service: virtual-machines
66
ms.topic: article
7-
ms.date: 09/21/2023
7+
ms.date: 09/25/2023
88
ms.author: ankitadutta
99
---
1010

@@ -28,6 +28,7 @@ Ensure the following before you begin:
2828
- **VM support**: Check that the VMs you want to move are supported. [Learn more](../reliability/migrate-vm.md). Check supported VM settings.
2929

3030
- **Subscription quota**: The subscription must have enough quota to create the new VM and associated networking resources in target zonal configuration (in same region). If the subscription doesn't have enough quota, you need to [request additional limits](../azure-resource-manager/management/azure-subscription-service-limits.md).
31+
- **VM health status**: The VMs you want to move must be in a healthy state before attempting the zonal move. Ensure that all pending reboots and mandatory updates are complete. [Learn more](../reliability/migrate-vm.md#vm-health-status) about VM health status.
3132

3233
## Select and move VMs
3334

articles/virtual-machines/move-virtual-machines-regional-zonal-powershell.md

Lines changed: 119 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Move single instance Azure virtual machines from a regional configu
44
author: ankitaduttaMSFT
55
ms.service: virtual-machines
66
ms.topic: tutorial
7-
ms.date: 09/21/2023
7+
ms.date: 09/25/2023
88
ms.author: ankitadutta
99
---
1010

@@ -73,6 +73,8 @@ The MoveCollection object stores metadata and configuration information about th
7373

7474
Use the following cmdlet to create a resource group for the move collection metadata and configuration information with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup). A resource group is a logical container into which Azure resources are deployed and managed.
7575

76+
# [PowerShell](#tab/PowerShell)
77+
7678
```powershell-interactive
7779
New-AzResourceGroup -Name "RegionToZone-DemoMCRG" -Location "EastUS"
7880
```
@@ -82,6 +84,19 @@ The output shows that the managed disk is in the same availability zone as the V
8284

8385
:::image type="content" source="./media/tutorial-move-regional-zonal/create-resource-group.png" alt-text="Output text after creating resource group":::
8486

87+
# [CLI](#tab/CLI)
88+
89+
```azurecli-interactive
90+
az group create --location eastus2 --name clidemo-RG
91+
```
92+
93+
**Output**:
94+
The output shows that the managed disk is in the same availability zone as the VM:
95+
96+
:::image type="content" source="./media/tutorial-move-regional-zonal/create-resource-group.png" alt-text="Output text after creating resource group":::
97+
98+
---
99+
85100
## Register the resource provider
86101

87102
1. Register the resource provider Microsoft.Migrate, so that the MoveCollection resource can be created, as follows:
@@ -104,6 +119,8 @@ The output shows that the managed disk is in the same availability zone as the V
104119
105120
Create a MoveCollection object, and assign a managed identity to it, as follows:
106121
122+
# [PowerShell](#tab/PowerShell)
123+
107124
```azurepowershell-interactive
108125
New-AzResourceMoverMoveCollection -Name "RegionToZone-DemoMC" -ResourceGroupName "RegionToZone-DemoMCRG" -MoveRegion "eastus" -Location "eastus2euap" -IdentityType "SystemAssigned" -MoveType "RegionToZone"
109126
```
@@ -112,6 +129,14 @@ New-AzResourceMoverMoveCollection -Name "RegionToZone-DemoMC" -ResourceGroupNam
112129

113130
:::image type="content" source="./media/tutorial-move-regional-zonal/create-move-collection.png" alt-text="Output text after creating move collection":::
114131

132+
# [CLI](#tab/CLI)
133+
134+
```azurecli-interactive
135+
az resource-mover move-collection create --identity type=SystemAssigned --location eastus2 --move-region uksouth --name cliDemo-zonalMC --resource-group clidemo-RG --move-type RegionToZone
136+
```
137+
138+
---
139+
115140
>[!NOTE]
116141
> For Regional to zonal move, the `MoveType` parameter should be set as *RegionToZone* and `MoveRegion` parameter should be set as the location where resources undergoing zonal move reside. Ensure that the parameters `SourceRegion` and `TargetRegion` are not required and should be set to *null*.
117142
@@ -128,35 +153,46 @@ Grant the managed identity access to the Resource Mover subscription as follows.
128153
129154
2. Assign the required roles to the identity so Azure Resource Mover can access your subscription to help move resources. Review the list of [required permissions](../resource-mover/common-questions.md#what-managed-identity-permissions-does-resource-mover-need) for the move.
130155
156+
# [PowerShell](#tab/PowerShell)
157+
158+
131159
```azurepowershell-interactive
132160
New-AzRoleAssignment -ObjectId $identityPrincipalId -RoleDefinitionName Contributor -Scope "/subscriptions/<subscription-id>""
133161
New-AzRoleAssignment -ObjectId $identityPrincipalId -RoleDefinitionName "User Access Administrator" -Scope "/subscriptions/<subscription-id>"
134162
```
135163
164+
# [CLI](#tab/CLI)
165+
166+
```azurecli-interactive
167+
az role assignment create --assignee-object-id 45bc279c-3353-4f6a-bb4f-8efb48faba59 --assignee-principal-type ServicePrincipal --role Contributor --scope /subscriptions/<Subscription-id>
168+
az role assignment create --assignee-object-id 45bc279c-3353-4f6a-bb4f-8efb48faba59 --assignee-principal-type ServicePrincipal --role "User Access Administrator" --scope /subscriptions/<Subscription-id>
169+
170+
```
171+
172+
---
173+
136174
## Add regional VMs to the move collection
137175
138176
Retrieve the IDs for existing source resources that you want to move. Create the destination resource settings object, then add resources to the move collection.
139177
140178
> [!NOTE]
141179
> Resources added to a move collection must be in the same subscription but can be in different resource groups.
142180
143-
### Create target resource setting object
144-
145-
Create the target resource setting object as follows:
181+
1. Create target resource setting object as follows:
146182
147-
```azurepowershell-interactive
148-
$targetResourceSettingsObj = New-Object Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api20230801.VirtualMachineResourceSettings
149-
$targetResourceSettingsObj.ResourceType = "Microsoft.Compute/virtualMachines"
150-
$targetResourceSettingsObj.TargetResourceName = "RegionToZone-demoTargetVm"
151-
$targetResourceSettingsObj.TargetAvailabilityZone = "2"
152-
```
153-
**Output**
154-
:::image type="content" source="./media/tutorial-move-regional-zonal/create-target-resources.png" alt-text="Output text after creating target regions the move collection.":::
183+
```azurepowershell-interactive
184+
$targetResourceSettingsObj = New-Object Microsoft.Azure.PowerShell.Cmdlets.ResourceMover.Models.Api20230801.VirtualMachineResourceSettings
185+
$targetResourceSettingsObj.ResourceType = "Microsoft.Compute/virtualMachines"
186+
$targetResourceSettingsObj.TargetResourceName = "RegionToZone-demoTargetVm"
187+
$targetResourceSettingsObj.TargetAvailabilityZone = "2"
188+
```
189+
**Output**
190+
:::image type="content" source="./media/tutorial-move-regional-zonal/create-target-resources.png" alt-text="Output text after creating target regions the move collection.":::
155191
156192
157-
### Add resources
193+
1. Add resources
158194
159-
1. Get the source resource ID:
195+
# [PowerShell](#tab/PowerShell)
160196
161197
```azurepowershell-interactive
162198
Add-AzResourceMoverMoveResource -ResourceGroupName "RegionToZone-DemoMCRG" -MoveCollectionName "RegionToZone-DemoMC" -SourceId "/subscriptions/<Subscription-id>/resourcegroups/PS-demo-RegionToZone-RG/providers/Microsoft.Compute/virtualMachines/RegionToZone-demoSourceVm" -Name "demoVM-MoveResource" -ResourceSetting $targetResourceSettingsObj
@@ -166,8 +202,18 @@ $targetResourceSettingsObj.TargetAvailabilityZone = "2"
166202
167203
:::image type="content" source="./media/tutorial-move-regional-zonal/add-regional-machines.png" alt-text="Output text after adding regional virtual machines to the move collection.":::
168204
205+
# [CLI](#tab/CLI)
206+
207+
```azurecli-interactive
208+
az resource-mover move-resource add --resource-group clidemo-RG --move-collection-name cliDemo-zonalMC --name vm-demoMR --source-id "/subscriptions/<Subscription-id>/resourceGroups/regionToZone-bugBash/providers/Microsoft.Compute/virtualMachines/regionToZone-test-LRS" --resource-settings '{ "resourceType": "Microsoft.Compute/virtualMachines", "targetResourceName": "regionToZone-test-LRS", "targetAvailabilityZone": "2", "targetVmSize": "Standard_B2s" }'
209+
```
210+
**Output**
211+
212+
:::image type="content" source="./media/tutorial-move-regional-zonal/add-regional-machines.png" alt-text="Output text after adding regional virtual machines to the move collection.":::
213+
214+
---
169215
170-
### Modify settings
216+
## Modify settings
171217
172218
You can modify destination settings when moving Azure VMs and associated resources. We recommend that you only change destination settings before you validate the move collection.
173219
@@ -215,6 +261,8 @@ Modify settings as follows:
215261
Check whether the regional VMs you added have any dependencies on other resources, and add as needed.
216262
217263
Resolve dependencies as follows:
264+
265+
# [PowerShell](#tab/PowerShell)
218266
219267
```
220268
Resolve-AzResourceMoverMoveCollectionDependency -ResourceGroupName "RegionToZone-DemoMCRG" -MoveCollectionName "RegionToZone-DemoMC"
@@ -224,20 +272,42 @@ Resolve-AzResourceMoverMoveCollectionDependency -ResourceGroupName "RegionToZone
224272
225273
:::image type="content" source="./media/tutorial-move-regional-zonal/resolve-dependencies.png" alt-text="Output text after resolving move dependencies.":::
226274
275+
# [CLI](#tab/CLI)
227276
228-
>[!NOTE]
229-
>
230-
> - To get a list of resources added to the move collection, you can call: <br>
231-
>`$list = Get-AzResourceMoverMoveResource -ResourceGroupName "RegionToZone-DemoMCRG" -MoveCollectionName "RegionToZone-DemoMC" $list.Name`
232-
> <br>
233-
>**Output:** <br>
234-
>:::image type="content" source="./media/tutorial-move-regional-zonal/call-move-collection.png" alt-text="Output text after retrieving the move collection.":::
235-
>
236-
> - To remove resources from the resource collection, follow these [instructions](../resource-mover/remove-move-resources.md).
277+
```azurecli-interactive
278+
az resource-mover move-collection resolve-dependency --name cliDemo-zonalMC --resource-group clidemo-RG
279+
```
280+
**Output (when dependencies exist)**
281+
282+
:::image type="content" source="./media/tutorial-move-regional-zonal/resolve-dependencies.png" alt-text="Output text after resolving move dependencies.":::
283+
284+
---
285+
286+
287+
- To get a list of resources added to the move collection, you can call:
288+
# [PowerShell](#tab/PowerShell)
289+
290+
```azurepowershell-interactive
291+
$list = Get-AzResourceMoverMoveResource -ResourceGroupName "RegionToZone-DemoMCRG" -MoveCollectionName "RegionToZone-DemoMC" $list.Name
292+
```
293+
294+
**Output:**
295+
:::image type="content" source="./media/tutorial-move-regional-zonal/call-move-collection.png" alt-text="Output text after retrieving the move collection.":::
296+
297+
# [CLI](#tab/CLI)
298+
299+
```azurecli-interactive
300+
az resource-mover move-resource list --move-collection-name cliDemo-zonalMC --resource-group clidemo-RG
301+
```
302+
---
303+
304+
- To remove resources from the resource collection, follow these [instructions](../resource-mover/remove-move-resources.md).
237305
238306
239307
## Initiate move of VM resources
240308
309+
# [PowerShell](#tab/PowerShell)
310+
241311
```azurepowershell
242312
Invoke-AzResourceMoverInitiateMove -ResourceGroupName "RegionToZone-DemoMCRG" -MoveCollectionName "RegionToZone-DemoMC" -MoveResource $("demoVM-MoveResource") -MoveResourceInputType "MoveResourceId"
243313
```
@@ -246,6 +316,18 @@ Invoke-AzResourceMoverInitiateMove -ResourceGroupName "RegionToZone-DemoMCRG" -M
246316

247317
:::image type="content" source="./media/tutorial-move-regional-zonal/initiate-move-resources.png" alt-text="Output text after initiating the move.":::
248318

319+
# [CLI](#tab/CLI)
320+
321+
```azurecli-interactive
322+
az resource-mover move-collection initiate-move --move-resources "/subscriptions/<Subscription-id>/resourceGroups/clidemo-RG/providers/Microsoft.Migrate/moveCollections/cliDemo-zonalMC/moveResources/vm-demoMR" --validate-only false --name cliDemo-zonalMC --resource-group clidemo-RG
323+
```
324+
325+
**Output**
326+
327+
:::image type="content" source="./media/tutorial-move-regional-zonal/initiate-move-resources.png" alt-text="Output text after initiating the move.":::
328+
329+
---
330+
249331
## Commit
250332

251333
After the initial move, you can decide whether you want to commit the move or discard it. Commit completes the move to the target region. After committing, a source regional VM will be in a state of *Delete source pending* and you can decide if you want to delete it.
@@ -254,13 +336,26 @@ After the initial move, you can decide whether you want to commit the move or di
254336

255337
1. Commit the move as follows:
256338

339+
# [PowerShell](#tab/PowerShell)
340+
257341
```
258342
Invoke-AzResourceMover-VMZonalMoveCommit -ResourceGroupName "RG-MoveCollection-demoRMS" -MoveCollectionName "PS-centralus-westcentralus-demoRMS" -MoveResource $('psdemovm111', 'PSDemoRM-vnet','PSDemoVM-nsg', ‘PSDemoVM’) -MoveResourceInputType "MoveResourceId"
259343
```
260344
261345
**Output**
262346
**IMAGE**
263347
348+
# [CLI](#tab/CLI)
349+
350+
```azurecli-interactive
351+
az resource-mover move-collection commit --move-resources "/subscriptions/<Subscription-id>/resourceGroups/clidemo-RG/providers/Microsoft.Migrate/moveCollections/cliDemo-zonalMC/moveResources/vm-demoMR" --validate-only false --name cliDemo-zonalMC --resource-group clidemo-RG
352+
```
353+
354+
**Output**
355+
**IMAGE**
356+
357+
---
358+
264359
2. Verify that all regional VMs have moved to the target region:
265360
266361
```

0 commit comments

Comments
 (0)