Skip to content

Commit 57732ac

Browse files
committed
some edits
1 parent bb4d117 commit 57732ac

File tree

4 files changed

+93
-43
lines changed

4 files changed

+93
-43
lines changed
Lines changed: 93 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,121 @@
11
---
2-
title: Create and use ARM templates
3-
description: Learn how to view, edit, save, and store Azure Resource Manager (ARM) virtual machine (VM) templates, connect template repositories to labs, and use templates to create VMs.
2+
title: Create and use ARM templates for VMs
3+
description: Learn how to view, edit, and store Azure Resource Manager (ARM) virtual machine (VM) templates, connect your template repositories to your labs, and access templates to use for creating VMs.
44
ms.topic: how-to
55
ms.author: rosemalcolm
66
author: RoseHJM
77
ms.date: 03/07/2025
88
ms.custom: UpdateFrequency2
9+
10+
#customer intent: As a lab user, I want to know how to create, manage, and access ARM templates, so I can use the templates to create VMs and let other lab users access my templates.
911
---
1012

11-
# Create and use ARM templates in DevTest Labs
13+
# Create and use ARM templates for VMs in DevTest Labs
1214

1315
This article describes how DevTest Labs users can:
1416

1517
- View, edit, and save Azure Resource Manager (ARM) templates for creating Azure VMs.
16-
- Store ARM templates in source control repositories.
17-
- Connect ARM template repositories to Azure DevTest Labs so other lab users can access the templates.
18+
- Store the ARM templates in source control repositories.
19+
- Connect the ARM template repositories to Azure DevTest Labs so other lab users can access the templates.
1820

1921
[!INCLUDE [About Azure Resource Manager](~/reusable-content/ce-skilling/azure/includes/resource-manager-quickstart-introduction.md)]
2022

2123
ARM templates for VM creation use the [Microsoft.DevTestLab/labs/virtualmachines](/azure/templates/microsoft.devtestlab/2018-09-15/labs/virtualmachines?pivots=deployment-language-arm-template) resource type. Each lab VM created with this resource type appears as a separate item in the lab's **My virtual machines** list.
2224

23-
Lab users can use ARM templates to create and deploy Azure VMs. Users can create their own ARM templates, modify existing ARM templates to meet their needs, or access preconfigured templates from the public [DevTest Labs GitHub repository](https://github.com/Azure/azure-devtestlab).
25+
Lab users can create their own ARM templates, modify existing ARM templates to meet their needs, or access preconfigured templates from their own or others' private repositories or the public [DevTest Labs GitHub repository](https://github.com/Azure/azure-devtestlab).
26+
27+
To create and deploy Azure VMs by using an ARM template, you can use any of the following options:
28+
29+
- [Azure portal](/azure/azure-resource-manager/templates/deploy-portal)
30+
- [Azure CLI](/azure/azure-resource-manager/templates/deploy-cli)
31+
- [PowerShell](/azure/azure-resource-manager/templates/deploy-powershell)
32+
- [REST API](/azure/azure-resource-manager/templates/deploy-rest)
33+
- [Button in GitHub repository](/azure/azure-resource-manager/templates/deploy-to-azure-button)
34+
- [Azure Cloud Shell](/azure/azure-resource-manager/templates/deploy-cloud-shell)
35+
- [Azure Pipelines DevTest Labs Tasks extension](https://marketplace.visualstudio.com/items?itemName=ms-azuredevtestlabs.tasks)
36+
37+
For more information about deployment, see [Template deployment process](/azure/azure-resource-manager/templates/overview#template-deployment-process).
2438

2539
## Prerequisites
2640

27-
- At least **DevTest Lab User** role in a lab.
41+
- To view or save ARM templates while creating VMs, at least **DevTest Lab User** role in a DevTest Labs lab.
42+
- To enable public repositories or add template repositories to labs, at least **Contributor** role in the lab.
2843

44+
<a name="view-edit-and-save-arm-templates-for-vms"></a>
2945
## View and save ARM templates for VMs
3046

3147
You can customize and use an ARM template from any available Azure VM base to use for deploying more VMs of the same type.
3248

3349
1. On your lab's **Overview** page, select **Add** on the top toolbar.
3450
1. On the **Choose a base** page, select the VM base you want.
35-
1. On the **Create lab resource** page, configure settings and add desired artifacts to your template VM.
36-
1. On the **Advanced Settings** tab, select **View ARM template**.
37-
1. Copy and save the ARM template to use for creating VMs.
38-
1. Close the ARM template page.
39-
1. If you want to create an instance of the VM immediately, select **Create** at the bottom of the form.
40-
51+
1. On the **Create lab resource** tabs, configure settings and add desired artifacts to your template VM.
52+
1. On the **Advanced Settings** tab, select **View ARM template** under **Automation** at the bottom of the form.
53+
1. Copy and save the contents of the **View Azure Resource Manager template** page as a file named *azuredeploy.json*, and then close the page.
4154
:::image type="content" source="media/devtest-lab-use-arm-template/devtestlab-lab-copy-rm-template.png" alt-text="Screenshot that shows an ARM template to save for later use.":::
55+
1. If you want to create the VM or VMs immediately, select **Create** at the bottom of the **Create lab resource** page.
4256

4357
## Edit ARM templates for VMs
4458

45-
To reuse the ARM template to create more VMs, you can update the `parameters` section of your template file. You can also create a *parameters* JSON file that customizes just the parameters, without having to edit the main template file.
46-
47-
:::image type="content" source="media/devtest-lab-use-arm-template/devtestlab-lab-custom-params.png" alt-text="Customize parameters using a JSON file.":::
59+
When you reuse the ARM template to create more VMs, you can edit the values in your template file. To update only the `parameters` section of your template without having to edit the main template file, you can create and edit a separate file called *azuredeploy.parameters.json*.
60+
61+
For example, in training, demo, and trial scenarios, you can automatically delete VMs after a certain date so they don't keep incurring costs. When you create a lab VM in the Azure portal, you can specify the **Expiration date** on the **Advanced settings** tab. You can also add an `expirationDate` property to the `parameters` section of your template file. For an example, see [Create a new VM in a lab with a specified expiration date](https://github.com/Azure/azure-devtestlab/tree/master/samples/DevTestLabs/QuickStartTemplates/101-dtl-create-vm-username-pwd-customimage-with-expiration).
62+
63+
The following example ARM template `parameters` section includes an `expirationDate` parameter.
64+
65+
```json
66+
"parameters": {
67+
"newVMName": {
68+
"type": "string",
69+
"defaultValue": "vm01"
70+
},
71+
"labName": {
72+
"type": "string",
73+
"defaultValue": "Contoso1"
74+
},
75+
"size": {
76+
"type": "string",
77+
"defaultValue": "Standard_D2s_v3"
78+
},
79+
"userName": {
80+
"type": "string",
81+
"defaultValue": "labuser"
82+
},
83+
"hibernationEnabled": {
84+
"type": "bool"
85+
},
86+
"expirationDate": {
87+
"type": "string",
88+
"defaultValue": "2025-03-15T07:00:00.000Z"
89+
},
90+
"password": {
91+
"type": "securestring",
92+
"defaultValue": "[[[user/VmPassword]]"
93+
}
94+
}
95+
```
4896

4997
>[!TIP]
50-
>You can add the `_artifactsLocation` and `_artifactsLocationSasToken` parameters to your parameters section or file to create a URI value for automatically managing nested templates. For more information about nested templates, see [Deploy nested Azure Resource Manager templates for testing environments](deploy-nested-template-environments.md).
51-
52-
### Set VM expiration date
53-
54-
For scenarios such as training, demos, and trials, you can automatically delete VMs after a certain date so they don't keep incurring costs. When you create a lab VM in the Azure portal, you can specify an **Expiration date** on the **Advanced settings** tab.
55-
56-
You can also add an `expirationDate` property to the `parameters` section of your template file. For an example, see [Create a new VM in a lab with a specified expiration date](https://github.com/Azure/azure-devtestlab/tree/master/samples/DevTestLabs/QuickStartTemplates/101-dtl-create-vm-username-pwd-customimage-with-expiration).
98+
>To create a URI value for automatically managing *nested templates*, you can add the `_artifactsLocation` and `_artifactsLocationSasToken` parameters to your `parameters` section or file. For more information about nested templates, see [Deploy nested Azure Resource Manager templates for testing environments](deploy-nested-template-environments.md).
5799
58100
### Create multiple VMs at once from the same template
59101

60-
You can specify more than one instance of a template VM to be created at a time. When you create a lab VM in the Azure portal, you can specify **Number of instances** on the **Advanced Settings** tab.
102+
You can specify more than one instance of a template VM to be created at one time. When you create a lab VM in the Azure portal, you can specify **Number of instances** on the **Advanced Settings** tab. To add or change the number of instances in a reusable ARM template, you can edit or add the `copy: count` value in the `resources` section of the template.
61103

62-
To add or change the number of instances in a reusable JSON template, you can edit or add the `copy/count` value to the `resources` section of the template.
104+
The following example ARM template `resources` section specifies creating two VMs.
63105

64-
There are two other options for simultaneously creating multiple VMs from the same template:
65-
66-
- Use the [Azure DevOps Tasks extension](https://marketplace.visualstudio.com/items?itemName=ms-azuredevtestlabs.tasks)
67-
- [Use Windows PowerShell to deploy the generated ARM template](/azure/azure-resource-manager/templates/deploy-powershell)
106+
```json
107+
"resources": [
108+
{
109+
"apiVersion": "2018-10-15-preview",
110+
"type": "Microsoft.DevTestLab/labs/virtualmachines",
111+
"name": "[concat(variables('vmName'), padLeft(copyIndex(), 3, '0'))]",
112+
"location": "[resourceGroup().location]",
113+
"copy": {
114+
"name": "[parameters('newVMName')]",
115+
"count": 2
116+
},
117+
...
118+
```
68119

69120
<a name="configure-your-own-template-repositories"></a>
70121
<a name="create-your-own-template-repositories"></a>
@@ -91,39 +142,38 @@ The following screenshot shows a typical ARM template folder structure in a repo
91142

92143
## Add template repositories to labs
93144

94-
To add your private ARM template repository to the lab so all lab users can access your templates:
145+
To see and access the template repositories available to your lab:
95146

96147
1. On the lab's **Overview** page, select **Configuration and policies** from the left navigation.
97148
1. On the **Configuration and policies** page, select **Repositories** under **External resources** in the left navigation.
98-
1. Select **Add** in the top menu bar.
99149

100-
:::image type="content" source="media/devtest-lab-create-environment-from-arm/public-repo.png" alt-text="Screenshot that shows the Repositories configuration screen.":::
150+
The **Public Artifact Repo** and **Public Environment Repo** at the [DevTest Labs public GitHub repository](https://github.com/Azure/azure-devtestlab) are available for all labs. If these repos aren't enabled for your lab, a lab owner or contributor can enable them by selecting the checkboxes next to **Public Artifact Repo** and **Public Environment Repo**, and then selecting **Enable** on the top menu bar. For more information, see [Enable and configure public environments](devtest-lab-create-environment-from-arm.md#configure-public-environment-settings).
151+
152+
If you're a lab owner or contributor, you can add your private ARM template repository to the lab so all lab users can access your templates.
153+
154+
1. On the **Repositories** page, select **Add** in the top menu bar.
155+
156+
:::image type="content" source="media/devtest-lab-use-arm-template/public-repo.png" alt-text="Screenshot that shows the Repositories configuration screen.":::
101157

102158
1. In the **Repositories** pane, enter the following information:
103159

104160
- **Name**: Enter the repository name to use in the lab.
105161
- **Git clone URL**: Enter the Git HTTPS clone URL from GitHub or Azure Repos.
106162
- **Branch** (optional): Enter the branch that has your ARM template definitions.
107163
- **Personal access token**: Enter the personal access token to securely access your repository.
108-
- To get a token from Azure Repos, select **User settings** > **Personal access tokens**.
164+
- To get a token from Azure Repos, at upper right select **User settings** > **Personal access tokens**.
109165
- To get a token from GitHub, under your profile, select **Settings** > **Developer settings** > **Personal access tokens**.
110166
- **Folder paths**: Enter the folder for your ARM template definitions, relative to the Git clone URI.
111167

112168
1. Select **Save**.
113169

114-
:::image type="content" source="media/devtest-lab-create-environment-from-arm/repo-values.png" alt-text="Screenshot that shows adding a new template repository to a lab.":::
170+
:::image type="content" source="media/devtest-lab-use-arm-template/repo-values.png" alt-text="Screenshot that shows settings for adding a new template repository to a lab.":::
115171

116172
The repository now appears in the **Repositories** list for the lab. Lab users can use the repository templates to [create multi-VM DevTest Labs environments](devtest-lab-create-environment-from-arm.md). Lab administrators can use the templates to [automate lab deployment and management tasks](devtest-lab-use-arm-and-powershell-for-lab-resources.md#arm-template-automation).
117173

118-
>[!NOTE]
119-
>On the **Repositories** page, the **Public Artifact Repo** and **Public Environment Repo** are available for all labs. These links connect to the [DevTest Labs public GitHub repository](https://github.com/Azure/azure-devtestlab).
120-
>
121-
>If these repos aren't enabled for your lab, a lab owner or contributor can enable them by selecting the checkboxes next to **Public Artifact Repo** and **Public Environment Repo**, and then selecting **Enable** on the top menu bar. For more information, see [Enable and configure public environments](devtest-lab-create-environment-from-arm.md#configure-public-environment-settings).
122-
123-
124-
### Related content
174+
## Related content
125175

126-
- [Best practices for creating Azure Resource Manager templates](/azure/azure-resource-manager/templates/best-practices)
127-
- [Add a Git repository to store custom artifacts and Resource Manager templates](devtest-lab-add-artifact-repo.md)
176+
- [Best practices for creating ARM templates](/azure/azure-resource-manager/templates/best-practices)
177+
- [Add a Git repository to store custom artifacts and ARM templates](devtest-lab-add-artifact-repo.md)
128178
- [Use ARM templates to create DevTest Labs environments](devtest-lab-create-environment-from-arm.md)
129179
- [ARM quickstart templates for DevTest Labs automation](https://github.com/Azure/azure-quickstart-templates)
-21.5 KB
Loading
70.9 KB
Loading
-9.55 KB
Loading

0 commit comments

Comments
 (0)