title | description | services | documentationcenter | author | manager | editor | ms.service | ms.workload | ms.tgt_pltfrm | ms.devlang | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Create and manage virtual machines in DevTest Labs with Azure CLI | Microsoft Docs |
Learn how to use Azure DevTest Labs to create and manage virtual machines with Azure CLI 2.0 |
devtest-lab,virtual-machines |
na |
lisawong19 |
douge |
devtest-lab |
na |
na |
na |
article |
05/19/2017 |
liwong |
This quick start will guide you through creating, starting, connecting, updating and cleaning up a development machine in your lab.
Before you begin:
-
If a lab has not been created, instructions can be found here.
-
Install CLI 2.0. To start, run az login to create a connection with Azure.
Create a VM from a marketplace image with ssh authentication.
az lab vm create --lab-name sampleLabName --resource-group sampleLabResourceGroup --name sampleVMName --image "Ubuntu Server 16.04 LTS" --image-type gallery --size Standard_DS1_v2 --authentication-type ssh --generate-ssh-keys --ip-configuration public
Note
Put the lab's resource group name in the --resource-group parameter.
If you want to create a VM using a formula, use the --formula parameter in az lab vm create.
Verify that the VM is available.
az lab vm show --lab-name sampleLabName --name sampleVMName --resource-group sampleResourceGroup --expand 'properties($expand=ComputeVm,NetworkInterface)' --query '{status: computeVm.statuses[0].displayStatus, fqdn: fqdn, ipAddress: networkInterface.publicIpAddress}'
{
"fqdn": "lisalabvm.southcentralus.cloudapp.azure.com",
"ipAddress": "13.85.228.112",
"status": "Provisioning succeeded"
}
Start a VM.
az lab vm start --lab-name sampleLabName --name sampleVMName --resource-group sampleLabResourceGroup
Note
Put the lab's resource group name in the --resource-group parameter.
Connect to a VM: SSH or Remote Desktop.
ssh userName@ipAddressOrfqdn
Apply artifacts to a VM.
az lab vm apply-artifacts --lab-name sampleLabName --name sampleVMName --resource-group sampleResourceGroup --artifacts @/artifacts.json
[
{
"artifactId": "/artifactSources/public repo/artifacts/linux-java",
"parameters": []
},
{
"artifactId": "/artifactSources/public repo/artifacts/linux-install-nodejs",
"parameters": []
},
{
"artifactId": "/artifactSources/public repo/artifacts/linux-apt-package",
"parameters": [
{
"name": "packages",
"value": "abcd"
},
{
"name": "update",
"value": "true"
},
{
"name": "options",
"value": ""
}
]
}
]
List artifacts available in the lab.
az lab vm show --lab-name sampleLabName --name sampleVMName --resource-group sampleResourceGroup --expand "properties(\$expand=artifacts)" --query 'artifacts[].{artifactId: artifactId, status: status}'
{
"artifactId": "/subscriptions/abcdeftgh1213123/resourceGroups/lisalab123RG822645/providers/Microsoft.DevTestLab/labs/lisalab123/artifactSources/public repo/artifacts/linux-install-nodejs",
"status": "Succeeded"
}
Stop a VM.
az lab vm stop --lab-name sampleLabName --name sampleVMName --resource-group sampleResourceGroup
Delete a VM.
az lab vm delete --lab-name sampleLabName --name sampleVMName --resource-group sampleResourceGroup
[!INCLUDE devtest-lab-try-it-out]