Skip to content

Commit 4d22c18

Browse files
authored
Merge pull request #70412 from spelluru/importvms0321
Import VMS
2 parents 41bab65 + 968e0f9 commit 4d22c18

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

articles/lab-services/TOC.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
href: classroom-labs/how-to-create-schedules.md
7777
- name: Create an environment with multiple VMs inside a template VM
7878
href: classroom-labs/how-to-enable-multi-vm-environment.md
79-
- name: DevTest labs
79+
- name: DevTest Labs
8080
items:
8181
- name: Specify resource group for lab virtual machines
8282
href: resource-group-control.md
@@ -88,6 +88,8 @@
8888
href: test-app-azure.md
8989
- name: Export or delete personal data
9090
href: personal-data-delete-export.md
91+
- name: Import virtual machines from another lab
92+
href: import-virtual-machines-from-another-lab.md
9193
- name: Set up DevTest Labs infrastructure in your enterprise
9294
href: devtest-lab-guidance-prescriptive-adoption.md
9395
items:
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: Import virtual machines from another lab in Azure DevTest Labs | Microsoft Docs
3+
description: Learn how to import virtual machines from another lab into the current lab.
4+
services: devtest-lab, lab-services
5+
documentationcenter: na
6+
author: spelluru
7+
manager: femila
8+
9+
ms.service: lab-services
10+
ms.workload: na
11+
ms.tgt_pltfrm: na
12+
ms.devlang: na
13+
ms.topic: article
14+
ms.date: 03/21/2019
15+
ms.author: spelluru
16+
17+
---
18+
19+
# Import virtual machines from another lab in Azure DevTest Labs
20+
This article provides information about how to import virtual machines from another lab into your lab.
21+
22+
## Scenarios
23+
Here are some scenarios where you need to import VMs from one lab into another lab:
24+
25+
- An individual on the team is moving to another group within the enterprise and wants to take the developer desktop to the new team’s DevTest Labs.
26+
- The group has hit a [subscription-level quota](../azure-subscription-service-limits.md) and wants to split up the teams into a few subscriptions
27+
- The company is moving to Express Route (or some other new networking topology) and the team wants to move the Virtual Machines to use this new infrastructure
28+
29+
## Solution and constraints
30+
This feature enables you to import VMs in one lab (source) into another lab (destination). You can optionally give a new name for the destination VM in the process. The import process includes all the dependencies like disks, schedules, network settings, and so on.
31+
32+
The process does take some time and is impacted by the following factors:
33+
34+
- Number/size of the disks that are attached to the source machine (since it’s a copy operation and not a move operation)
35+
- Distance to the destination (For example, East US region to Southeast Asia).
36+
37+
Once the process is complete, the source Virtual Machine remains shutdown and the new one is running in the destination lab.
38+
39+
There are two key constraints to be aware of when planning to import VMs from one lab in to another lab:
40+
41+
- Virtual Machine imports across subscriptions and across regions are supported, but the subscriptions must be associated to the same Azure Active Directory tenant.
42+
- Virtual Machines must not be in a claimable state in the source lab.
43+
- You're the owner of the VM in the source lab and owner of the lab in the destination lab.
44+
- Currently, this feature is supported only through Powershell and REST API.
45+
46+
## Use PowerShell
47+
Download ImportVirtualMachines.ps1 file from the [GitHub](https://github.com/Azure/azure-devtestlab/blob/master/Scripts/ImportVirtualMachines/ImportVirtualMachines.ps1). You can use the script to import a single VM or all VMs in the source lab into the destination lab.
48+
49+
### Use PowerShell to import a single VM
50+
Executing this powershell script requires identifying the source VM and the destination lab, and optionally supplying a new name to use for the destination machine:
51+
52+
```powershell
53+
./ImportVirtualMachines.ps1 -SourceSubscriptionId "<ID of the subscription that contains the source lab>" `
54+
-SourceDevTestLabName "<Name of the source lab>" `
55+
-SourceVirtualMachineName "<Name of the VM to be imported from the source lab> " `
56+
-DestinationSubscriptionId "<ID of the subscription that contians the destination lab>" `
57+
-DestinationDevTestLabName "<Name of the destination lab>" `
58+
-DestinationVirtualMachineName "<Optional: specify a new name for the imported VM in the destination lab>"
59+
```
60+
61+
### Use PowerShell to import all VMs in the source lab
62+
If the Source Virtual Machine isn’t specified, the script automatically imports all VMs in the DevTest Labs. For example:
63+
64+
```powershell
65+
./ImportVirtualMachines.ps1 -SourceSubscriptionId "<ID of the subscription that contains the source lab>" `
66+
-SourceDevTestLabName "<Name of the source lab>" `
67+
-DestinationSubscriptionId "<ID of the subscription that contians the destination lab>" `
68+
-DestinationDevTestLabName "<Name of the destination lab>"
69+
```
70+
71+
## Use HTTP REST to import a VM
72+
The REST call is simple. You give enough information to identify the source and destination resources. Remember that the operation takes place on the destination lab resource.
73+
74+
```REST
75+
POST https://management.azure.com/subscriptions/<DestinationSubscriptionID>/resourceGroups/<DestinationResourceGroup>/providers/Microsoft.DevTestLab/labs/<DestinationLab>/ImportVirtualMachine?api-version=2017-04-26-preview
76+
{
77+
sourceVirtualMachineResourceId: "/subscriptions/<SourceSubscriptionID>/resourcegroups/<SourceResourceGroup>/providers/microsoft.devtestlab/labs/<SourceLab>/virtualmachines/<NameofVMTobeImported>",
78+
destinationVirtualMachineName: "<NewNameForImportedVM>"
79+
}
80+
```
81+
82+
## Next steps
83+
See the following articles:
84+
85+
- [Set policies for a lab](devtest-lab-get-started-with-lab-policies.md)
86+
- [Frequently asked questions](devtest-lab-faq.md)

0 commit comments

Comments
 (0)