You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/devtest-labs/devtest-lab-use-resource-manager-template.md
+39-40Lines changed: 39 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
---
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.
2
+
title: Create and manage ARM VM templates
3
+
description: Learn how to view, edit, store, and access Azure Resource Manager (ARM) virtual machine (VM) templates, and how lab admins can add template repositories to labs.
4
4
ms.topic: how-to
5
5
ms.author: rosemalcolm
6
6
author: RoseHJM
7
-
ms.date: 03/07/2025
7
+
ms.date: 03/10/2025
8
8
ms.custom: UpdateFrequency2
9
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.
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.
11
11
---
12
12
13
-
# Create and use ARM templates for VMs in DevTest Labs
13
+
# Create and manage ARM VM templates in DevTest Labs
14
14
15
15
This article describes how DevTest Labs users can:
16
16
@@ -22,46 +22,40 @@ This article describes how DevTest Labs users can:
22
22
23
23
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.
24
24
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:
For more information about deployment, see [Template deployment process](/azure/azure-resource-manager/templates/overview#template-deployment-process).
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) to use in creating VMs.
38
26
39
27
## Prerequisites
40
28
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.
29
+
- To view or save ARM templates while creating VMs, at least **DevTest Lab User** role in a lab.
30
+
- To enable public repositories or add private template repositories to labs, at least **Contributor** role in the lab.
You can customize and use an ARM template from any available Azure VM base to use for deploying more VMs of the same type.
35
+
You can customize and use an ARM template from any available Azure VM base to use for deploying more VMs of the same type. To customize and save an ARM template in the Azure portal:
48
36
49
37
1. On your lab's **Overview** page, select **Add** on the top toolbar.
50
38
1. On the **Choose a base** page, select the VM base you want.
51
39
1. On the **Create lab resource** tabs, configure settings and add desired artifacts to your template VM.
52
40
1. On the **Advanced Settings** tab, select **View ARM template** under **Automation** at the bottom of the form.
53
41
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.
42
+
54
43
:::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.
44
+
45
+
1. If you want to create the VM immediately, select **Create** at the bottom of the **Create lab resource** page.
46
+
47
+
For more information on creating lab VMs, see [Create lab virtual machines in Azure DevTest Labs](devtest-lab-add-vm.md).
56
48
57
49
<aname="set-vm-expiration-date"></a>
58
50
## Edit ARM templates for VMs
59
51
60
-
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*.
52
+
When you reuse the ARM template to create more VMs, you can edit the `parameters` in your template file. You can create and edit a separate file called *azuredeploy.parameters.json* to update only the parameters without having to edit the main template file.
53
+
54
+
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 specify the **Expiration date** on the **Advanced settings** tab.
61
55
62
-
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).
56
+
You can add an `expirationDate` property to your ARM template `parameters` section or file. For an example template, 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).
63
57
64
-
The following example ARM template `parameters` section includes an `expirationDate` parameter.
58
+
The following example `parameters` section includes an `expirationDate` parameter.
65
59
66
60
```json
67
61
"parameters": {
@@ -98,24 +92,15 @@ The following example ARM template `parameters` section includes an `expirationD
98
92
>[!TIP]
99
93
>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).
100
94
101
-
### Create multiple VMs at once from the same template
95
+
### Create multiple VMs at once
102
96
103
-
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.
104
-
105
-
The following example ARM template `resources` section specifies creating two VMs.
97
+
In the Azure portal, you can create more than one instance of a VM at a time by specifying **Number of instances** on the **Advanced Settings** tab of the VM creation screen. In the ARM template, the `copy` parameter in the `resources` section determines the number of instances to create.
@@ -128,7 +113,7 @@ Use the following file structure to store an ARM template in a source control re
128
113
129
114
- Name the main template file *azuredeploy.json*.
130
115
- Name any standalone parameter customization file *azuredeploy.parameters.json*.
131
-
- Optionally, define metadata that specifies the template display name and description in a file named *metadata.json*.
116
+
- Optionally, define metadata that specifies the template display name and description in a file named *metadata.json*, as follows:
132
117
133
118
```json
134
119
{
@@ -150,28 +135,42 @@ To see and access the template repositories available to your lab:
150
135
151
136
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).
152
137
153
-
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.
138
+
If you're a lab owner or contributor, you can add a private ARM template repository to the lab so all lab users can access the templates.
154
139
155
140
1. On the **Repositories** page, select **Add** in the top menu bar.
156
141
157
142
:::image type="content" source="media/devtest-lab-use-arm-template/public-repo.png" alt-text="Screenshot that shows the Repositories configuration screen.":::
158
143
159
144
1. In the **Repositories** pane, enter the following information:
160
145
161
-
- **Name**: Enter the repository name to use in the lab.
146
+
-**Name**: Enter the repository name.
162
147
-**Git clone URL**: Enter the Git HTTPS clone URL from GitHub or Azure Repos.
163
148
-**Branch** (optional): Enter the branch that has your ARM template definitions.
164
149
-**Personal access token**: Enter the personal access token to securely access your repository.
165
150
- To get a token from Azure Repos, at upper right select **User settings** > **Personal access tokens**.
166
151
- To get a token from GitHub, under your profile, select **Settings** > **Developer settings** > **Personal access tokens**.
167
-
- **Folder paths**: Enter the folder for your ARM template definitions, relative to the Git clone URI.
152
+
-**Folder paths**: Enter the folder for the ARM template definitions, relative to the Git clone URI.
168
153
169
154
1. Select **Save**.
170
155
171
156
:::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.":::
172
157
173
158
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).
174
159
160
+
## Deploy VMs by using ARM templates
161
+
162
+
To create and deploy Azure VMs by using ARM templates, you can use any of the following methods:
For more information about deployment, see [Template deployment process](/azure/azure-resource-manager/templates/overview#template-deployment-process).
173
+
175
174
## Related content
176
175
177
176
-[Best practices for creating ARM templates](/azure/azure-resource-manager/templates/best-practices)
0 commit comments