Skip to content

Commit c241666

Browse files
committed
ps-cli
1 parent 6eb38ff commit c241666

File tree

3 files changed

+57
-56
lines changed

3 files changed

+57
-56
lines changed

articles/devtest-labs/devtest-lab-attach-detach-data-disk.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
22
title: Attach or detach data disks for lab VMs
3-
description: Learn how to attach or detach a data disk for a lab virtual machine (VM) in Azure DevTest Labs.
3+
description: Learn how to use the Azure portal to attach or detach a data disk for an Azure DevTest Labs virtual machine (VM).
44
ms.topic: how-to
55
ms.author: rosemalcolm
66
author: RoseHJM
77
ms.date: 03/14/2025
88
ms.custom: UpdateFrequency2
9+
10+
#customer intent: As a lab user, I want to attach and detach data disks for my DevTest Labs VMs so I can manage storage or software separately from individual VMs.
911
---
1012

1113
# Attach or detach a data disk for a lab VM in Azure DevTest Labs
1214

13-
This article explains how to attach and detach a lab virtual machine (VM) data disk in Azure DevTest Labs. You can create, attach, detach, and reattach multiple [data disks](/azure/virtual-machines/managed-disks-overview) for your lab VMs. Data disks let you manage storage or software separately from individual VMs.
15+
This article explains how to attach and detach a lab virtual machine (VM) data disk in Azure DevTest Labs by using the Azure portal. You can create, attach, detach, and reattach multiple [data disks](/azure/virtual-machines/managed-disks-overview) for your lab VMs. Data disks let you manage storage or software separately from individual VMs.
1416

1517
## Prerequisites
1618

@@ -94,7 +96,7 @@ You can also detach or delete a data disk from the lab's page.
9496

9597
:::image type="content" source="./media/devtest-lab-attach-detach-data-disk/devtest-lab-detach-data-disk.png" alt-text="Screenshot of detaching a data disk from the listing's context menu.":::
9698

97-
To delete a detached data disk, select **Delete** from the context menu on the **My data disks** page, or from the disk's page. Deleting a data disk removes it from storage, and you can't reattach it anymore.
99+
To delete a detached data disk, select **Delete** from the context menu on the **My data disks** page, or from the disk's page. Deleting a data disk removes it from storage, and you can no longer reattach it.
98100

99101
## Related content
100102

articles/devtest-labs/devtest-lab-concepts.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,27 @@ author: RoseHJM
77
ms.date: 03/14/2025
88
ms.custom: UpdateFrequency2
99

10-
#customer intent: As a lab user or administrator, I want to understand basic DevTest Labs concepts so I know how I can create, manage, or use labs, VMs, environments, and templates.
10+
#customer intent: As a lab user or administrator, I want to understand basic DevTest Labs concepts so I know how I can create, manage, and use labs, VMs, environments, and templates.
1111
---
1212

1313
# DevTest Labs concepts
1414

1515
This article describes key [Azure DevTest Labs](https://azure.microsoft.com/services/devtest-lab) concepts and definitions. DevTest Labs is a service for easily creating, using, and managing Azure virtual machines (VMs) and other resources.
1616

17-
## Roles
17+
## Labs
18+
19+
A DevTest Labs lab is the infrastructure that encompasses a group of resources such as VMs. DevTest Labs administrators can:
20+
21+
- Add and configure lab users.
22+
- Create ready-made VMs for lab users to claim and use.
23+
- Create and use templates to create and configure labs, VMs, and environments.
24+
- Connect artifact and template repositories to the lab.
25+
- Let users create and configure their own lab VMs and environments.
26+
- Specify allowed virtual machine (VM) limits, sizes, and configurations.
27+
- Set autoshutdown and autostartup policies.
28+
- Track and manage lab costs.
29+
30+
### Roles
1831

1932
[Azure role-based access control (Azure RBAC)](/azure/role-based-access-control/overview) defines DevTest Labs access and roles. DevTest Labs has three roles that define lab member permissions: **Owner**, **Contributor**, and **DevTest Labs User**.
2033

@@ -30,19 +43,7 @@ This article describes key [Azure DevTest Labs](https://azure.microsoft.com/serv
3043

3144
DevTest Labs Users can't modify lab policies, or change any other users' VMs. DevTest Labs Users automatically have Owner permissions on their own VMs.
3245

33-
## Labs
34-
35-
A DevTest Labs lab is the infrastructure that encompasses a group of resources such as VMs. Lab administrators can:
36-
37-
- Add and configure users (Owners only).
38-
- Create ready-made VMs for lab users to claim and use.
39-
- Connect artifact and template repositories to the lab.
40-
- Let users create and configure their own lab VMs and environments.
41-
- Specify allowed virtual machine (VM) limits, sizes, and configurations.
42-
- Set autoshutdown and autostartup policies.
43-
- Track and manage lab costs.
44-
45-
### Lab policies
46+
### Policies
4647

4748
Lab policies help control costs and reduce waste. For example, policies can automatically shut down lab VMs based on a defined schedule, or limit the number or sizes of VMs per user or lab. For more information, see [Manage lab policies to control costs](devtest-lab-set-lab-policy.md).
4849

@@ -100,6 +101,6 @@ For more information about custom images and formulas, see [Compare custom image
100101

101102
## Environments
102103

103-
A DevTest Labs environment is a collection of Azure platform-as-a-service (PaaS) resources, such as an Azure Web App or a SharePoint farm, defined by an Azure Resource Manager (ARM) template. Lab administrators can add public or privately created environment tamplates to labs, and lab users can use them to quickly create environments. For more information, see [Use ARM templates to create DevTest Labs environments](devtest-lab-create-environment-from-arm.md).
104+
A DevTest Labs environment is a collection of Azure platform-as-a-service (PaaS) resources, such as an Azure Web App or a SharePoint farm, that's defined by an Azure Resource Manager (ARM) template. Lab administrators can add public or privately created environment tamplates to labs, and lab users can use them to quickly create environments. For more information, see [Use ARM templates to create DevTest Labs environments](devtest-lab-create-environment-from-arm.md).
104105

105106
[!INCLUDE [devtest-lab-try-it-out](../../includes/devtest-lab-try-it-out.md)]

articles/devtest-labs/use-command-line-start-stop-virtual-machines.md

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
---
2-
title: Start & stop lab VMs with command lines
3-
description: Use Azure PowerShell or Azure CLI command lines and scripts to start and stop Azure DevTest Labs virtual machines.
2+
title: Start and stop lab VMs with command lines
3+
description: Use Azure PowerShell or Azure CLI command lines and scripts to start and stop Azure DevTest Labs virtual machines (VMs).
44
ms.topic: how-to
55
ms.author: rosemalcolm
66
author: RoseHJM
7-
ms.date: 09/30/2023
7+
ms.date: 03/14/2025
88
ms.custom: devx-track-azurepowershell, devx-track-azurecli, UpdateFrequency2
99
ms.devlang: azurecli
10-
---
1110

12-
# Use command lines to start and stop DevTest Labs virtual machines
11+
#customer intent: As a lab user, I want to use PowerShell or Azure CLI commands to start and stop VMs so I can support automated workflows and save costs.
12+
---
1313

14-
This article shows how to start or stop Azure DevTest Labs virtual machines (VMs) by using Azure PowerShell or Azure CLI command lines and scripts.
14+
# Use command lines to start and stop DevTest Labs VMs
1515

16-
You can start, stop, or [restart DevTest Labs VMs](devtest-lab-restart-vm.md) by using the Azure portal. You can also use the portal to configure [automatic startup](devtest-lab-auto-startup-vm.yml) and [automatic shutdown](devtest-lab-auto-shutdown.md) schedules and policies for lab VMs.
16+
This article shows how you can use PowerShell or Azure CLI commands to script or automate start or stop for Azure DevTest Labs VMs. For example, you can use start or stop commands to:
1717

18-
When you want to script or automate start or stop for lab VMs, use PowerShell or Azure CLI commands. For example, you can use start or stop commands to:
18+
- Test a three-tier application where the tiers need to start in a sequence.
19+
- Turn off your VMs to save costs when they meet custom criteria.
20+
- Start and stop a VM when a continuous integration and continuous delivery (CI/CD) workflow begins and finishes. For an example of this workflow, see [Run an image factory from Azure DevOps](image-factory-set-up-devops-lab.md).
1921

20-
- Test a three-tier application, where the tiers need to start in a sequence.
21-
- Turn off VMs to save costs when they meet custom criteria.
22-
- Start when a continuous integration and continuous delivery (CI/CD) workflow begins, and stop when it finishes. For an example of this workflow, see [Run an image factory from Azure DevOps](image-factory-set-up-devops-lab.md).
22+
You can also use the Azure portal to start, stop, or [restart](devtest-lab-restart-vm.md) DevTest Labs VMs. Lab admins can use the portal to configure [automatic startup](devtest-lab-auto-startup-vm.yml) and [automatic shutdown](devtest-lab-auto-shutdown.md) schedules and policies for lab VMs.
2323

2424
## Prerequisites
2525

26-
- A [lab VM in DevTest Labs](devtest-lab-add-vm.md).
27-
- For Azure PowerShell, the [Az PowerShell module](/powershell/azure/new-azureps-module-az) installed on your workstation. Make sure you have the latest version. If necessary, run `Update-Module -Name Az` to update the module.
28-
- For Azure CLI, [Azure CLI ](/cli/azure/install-azure-cli) installed on your workstation.
26+
- Access to Azure PowerShell. You can [use Azure Cloud Shell](/azure/cloud-shell/quickstart?tabs=powershell) in the Azure portal, or [install Azure PowerShell](/powershell/azure/install-azure-powershell) locally. If necessary, run `Update-Module -Name Az` to update your local installation.
27+
28+
- Ownership of a [lab VM in DevTest Labs](devtest-lab-add-vm.md).
29+
- Access to Azure CLI. You can [use Azure Cloud Shell](/azure/cloud-shell/quickstart?tabs=powershell) in the Azure portal, or install [Azure CLI ](/cli/azure/install-azure-cli) locally.
2930

3031
## Azure PowerShell script
3132

32-
The following PowerShell script starts or stops a VM in a lab by using [Invoke-AzResourceAction](/powershell/module/az.resources/invoke-azresourceaction). The `ResourceId` parameter is the fully qualified ID for the lab VM you want to start or stop. The `Action` parameter determines whether to start or stop the VM, depending on which action you need.
33+
The following PowerShell script starts or stops a VM in a lab by using the [Invoke-AzResourceAction](/powershell/module/az.resources/invoke-azresourceaction) PowerShell cmdlet. The `ResourceId` parameter is the fully qualified ID for the lab VM you want to start or stop. The `Action` parameter determines whether to start or stop the VM, depending on which action you need.
3334

34-
1. From your workstation, use the PowerShell [Connect-AzAccount](/powershell/module/Az.Accounts/Connect-AzAccount) cmdlet to sign in to your Azure account. If you have multiple Azure subscriptions, uncomment the `Set-AzContext` line and fill in the `<Subscription ID>` you want to use.
35+
1. In Cloud Shell, make sure the **PowerShell** environment is selected. Use the PowerShell [Connect-AzAccount](/powershell/module/Az.Accounts/Connect-AzAccount) cmdlet to sign in to your Azure account. If you have multiple Azure subscriptions, uncomment `Set-AzContext` and provide the `<SubscriptionId>` you want to use.
3536

3637
```powershell
3738
# Sign in to your Azure subscription
@@ -44,13 +45,11 @@ The following PowerShell script starts or stops a VM in a lab by using [Invoke-A
4445
# Set-AzContext -SubscriptionId "<Subscription ID>"
4546
```
4647
47-
1. Provide values for the *`<lab name>`* and *`<VM name>`*, and enter which action you want for *`<Start or Stop>`*.
48+
1. Set variables by providing your own values for `<lab name>`, `<VM name>`, and whether to `Start` or `Stop` the VM.
4849
4950
```powershell
5051
$devTestLabName = "<lab name>"
5152
$vMToStart = "<VM name>"
52-
53-
# The action on the virtual machine (Start or Stop)
5453
$vmAction = "<Start or Stop>"
5554
```
5655
@@ -76,44 +75,43 @@ The following PowerShell script starts or stops a VM in a lab by using [Invoke-A
7675
7776
## Azure CLI script
7877
79-
The following script provides [Azure CLI](/cli/azure/get-started-with-azure-cli) commands for starting or stopping a lab VM. The variables in this script are for a Windows environment, like a command prompt. Bash or other environments have slight variations.
78+
The Azure CLI [az lab vm start](/cli/azure/lab/vm#az-lab-vm-start) and [az lab vm stop](/cli/azure/lab/vm#az-lab-vm-stop) commands start or stop a lab VM.
8079
81-
1. Provide appropriate values for *`<Subscription ID>`*, *`<lab name>`*, *`<VM name>`*, and the *`<Start or Stop>`* action to take.
82-
83-
```azurecli
84-
set SUBSCRIPTIONID=<Subscription ID>
85-
set DEVTESTLABNAME=<lab name>
86-
set VMNAME=<VM name>
87-
set ACTION=<Start or Stop>
88-
```
80+
>[!NOTE]
81+
>This script assumes a Bash environment. The variables and command for a Windows environment, like a command prompt, have slight variations.
8982
90-
1. Sign in to your Azure account. If you have multiple Azure subscriptions, uncomment the `az account set` line to use the subscription ID you provided.
83+
1. In Cloud Shell, make sure the **Bash** environment is selected, and sign in to your Azure account. If you have multiple Azure subscriptions, uncomment the `az account set` line to use the subscription ID you provide.
9184
9285
```azurecli
9386
az login
9487
95-
REM az account set --subscription %SUBSCRIPTIONID%
88+
REM az account set --subscription <SubscriptionId>
9689
```
9790

98-
1. Get the name of the resource group that contains the lab.
91+
1. Set variables by providing values for `<SubscriptionId>`, `<resourceGroup>`, `<lab name>`, `<VM name>`, and whether to `Start` or `Stop` the VM.
9992

10093
```azurecli
101-
az resource list --resource-type "Microsoft.DevTestLab/labs" --name %DEVTESTLABNAME% --query "[0].resourceGroup"
94+
SUBSCRIPTIONID=<SubscriptionId>
95+
RESOURCEGROUP=<resourceGroup>
96+
DEVTESTLABNAME=<lab name>
97+
VMNAME=<VM name>
98+
ACTION=<Start or Stop>
10299
```
103100

104-
1. Replace *`<resourceGroup>`* with the value you got from the previous step.
101+
>[!TIP]
102+
>If you don't know the name of the Azure resource group that contains your lab, you can find it by providing your `<lab name>` in the following query.
105103
106104
```azurecli
107-
set RESOURCEGROUP=<resourceGroup>
105+
az resource list --resource-type "Microsoft.DevTestLab/labs" --name "<LabName>" --query "[0].resourceGroup"
108106
```
109107

110-
1. Run the command line to start or stop the VM, based on the value you passed to `ACTION`.
108+
1. Run the following Azure CLI command to start or stop the VM, based on the value passed to `ACTION`.
111109

112110
```azurecli
113-
az lab vm %ACTION% --lab-name %DEVTESTLABNAME% --name %VMNAME% --resource-group %RESOURCEGROUP%
111+
az lab vm $ACTION --lab-name $DEVTESTLABNAME --name $VMNAME --resource-group $RESOURCEGROUP
114112
```
115113

116-
## Next steps
114+
## Related content
117115

118116
- [Azure CLI az lab reference](/cli/azure/lab)
119117
- [PowerShell Az.DevTestLabs reference](/powershell/module/az.devtestlabs)

0 commit comments

Comments
 (0)