|
1 | 1 | ---
|
2 |
| -title: Add an artifact to a VM |
3 |
| -description: Learn how to add an artifact to a virtual machine in a lab in Azure DevTest Labs. |
| 2 | +title: Add artifacts to VMs |
| 3 | +description: Learn how to add or configure artifacts on lab virtual machines (VM) in Azure DevTest Labs by using the Azure portal or Azure PowerShell. |
4 | 4 | ms.topic: how-to
|
5 | 5 | ms.author: rosemalcolm
|
6 | 6 | author: RoseHJM
|
7 |
| -ms.date: 09/30/2023 |
| 7 | +ms.date: 03/26/2025 |
8 | 8 | ms.custom: devx-track-azurepowershell, UpdateFrequency2
|
| 9 | + |
| 10 | +#customer intent: As a lab user, I want to add artifacts to my VMs so I can use them to run scripts or commands, install tools or applications, or take other actions on my VMs. |
9 | 11 | ---
|
10 | 12 |
|
11 | 13 | # Add artifacts to DevTest Labs VMs
|
12 | 14 |
|
13 |
| -This article describes how to add *artifacts* to Azure DevTest Labs virtual machines (VMs). Artifacts specify actions to take to provision a VM, such as running Windows PowerShell scripts, running Bash commands, or installing software. You can use parameters to customize the artifacts for your own needs. |
| 15 | +This article describes how to add *artifacts* to Azure DevTest Labs virtual machines (VMs) by using the Azure portal or Azure PowerShell. Artifacts are tools, actions, or software you can add to lab VMs. For example, artifacts can run Windows PowerShell scripts or Bash commands, install tools or applications, or take other actions like joining a domain. |
| 16 | + |
| 17 | +DevTest Labs artifacts can come from the [public DevTest Labs Git repository](https://github.com/Azure/azure-devtestlab/tree/master/Artifacts) or from private Git repositories. Lab users can [create their own custom artifacts](devtest-lab-artifact-author.md) and store them in a repository, and use parameters to customize existing artifacts for their own needs. |
| 18 | + |
| 19 | +A lab administrator can [add artifact repositories to a lab](add-artifact-repository.md) so all lab users can access them. Lab administrators can also [specify mandatory artifacts to be installed on all lab VMs](devtest-lab-mandatory-artifacts.md) at creation. Lab users can't change or remove mandatory artifacts at VM creation time, but they can add and configure other available artifacts at or after VM creation time. |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +# [Azure portal](#tab/portal) |
| 24 | + |
| 25 | +- User access to a lab in DevTest Labs. |
14 | 26 |
|
15 |
| -DevTest Labs artifacts can come from the [public DevTest Labs Git repository](https://github.com/Azure/azure-devtestlab/tree/master/Artifacts) or from private Git repositories. To create your own custom artifacts and store them in a repository, see [Create custom artifacts](devtest-lab-artifact-author.md). To add your artifact repository to a lab so lab users can access the custom artifacts, see [Add an artifact repository to your lab](add-artifact-repository.md). |
| 27 | +# [Azure PowerShell](#tab/PowerShell) |
16 | 28 |
|
17 |
| -DevTest Labs lab owners can specify mandatory artifacts to be installed on all lab VMs at creation. For more information, see [Specify mandatory artifacts for DevTest Labs VMs](devtest-lab-mandatory-artifacts.md). |
| 29 | +- User access to a lab in DevTest Labs. |
| 30 | +- Azure PowerShell. You can either: |
| 31 | + - [Use Azure Cloud Shell](/azure/cloud-shell/quickstart). Be sure to select the **PowerShell** environment. |
| 32 | + - [Install Azure PowerShell](/powershell/azure/install-azure-powershell) to use on a physical or virtual machine. If necessary, run `Update-Module -Name Az` to update your installation. |
18 | 33 |
|
19 |
| -You can't change or remove mandatory artifacts at VM creation time, but you can add any available individual artifacts. This article describes how to add available artifacts to VMs by using the Azure portal or Azure PowerShell. |
| 34 | +--- |
20 | 35 |
|
21 |
| -## Add artifacts to VMs from the Azure portal |
| 36 | +## Add artifacts to VMs |
22 | 37 |
|
23 |
| -You can add artifacts during VM creation, or add artifacts to existing lab VMs. |
| 38 | +# [Azure portal](#tab/portal) |
| 39 | +<a name="add-artifacts-to-vms-from-the-azure-portal"></a> |
| 40 | +You can use the Azure portal to add artifacts during VM creation or to add artifacts to an existing lab VM. |
24 | 41 |
|
25 |
| -To add artifacts during VM creation: |
| 42 | +### Add artifacts during VM creation |
26 | 43 |
|
27 | 44 | 1. On the lab's home page, select **Add**.
|
28 | 45 | 1. On the **Choose a base** page, select the type of VM you want.
|
29 |
| -1. On the **Create lab resource** screen, select **Add or Remove Artifacts**. |
| 46 | +1. On the **Create lab resource** screen, fill out the **Basic Settings** tab according to the instructions at [Create lab VMs in Azure DevTest Labs](devtest-lab-add-vm.md). |
| 47 | +1. At the bottom of the **Basic Settings** tab, select **Add or Remove Artifacts**. |
30 | 48 | 1. On the **Add artifacts** page, select the arrow next to each artifact you want to add to the VM.
|
31 |
| -1. On each **Add artifact** pane, enter any required and optional parameter values, and then select **OK**. The artifact appears under **Selected artifacts**, and the number of configured artifacts updates. |
| 49 | +1. On each **Add artifact** pane, enter any required and optional parameter values, and then select **OK**. The artifact appears under **Selected artifacts** on the **Add artifacts** page, and the number of configured artifacts updates. |
| 50 | + |
| 51 | + :::image type="content" source="./media/add-artifact-vm/devtestlab-add-artifacts-blade-selected-artifacts.png" alt-text="Screenshot that shows adding artifacts."::: |
32 | 52 |
|
33 |
| - :::image type="content" source="./media/add-artifact-vm/devtestlab-add-artifacts-blade-selected-artifacts.png" alt-text="Screenshot that shows adding artifacts on the Add artifacts pane."::: |
| 53 | +1. By default, artifacts install in the order you add them. To rearrange the order, select the ellipsis **...** next to the artifact in the **Selected artifacts** list, and select **Move up**, **Move down**, **Move to top**, or **Move to bottom**. |
34 | 54 |
|
35 |
| -1. You can change the artifacts after adding them. |
| 55 | + - To edit an artifact's parameters after you add it, select the pencil icon or select **...** next to the artifact and select **Edit** to reopen the artifact pane. |
36 | 56 |
|
37 |
| - - By default, artifacts install in the order you add them. To rearrange the order, select the ellipsis **...** next to the artifact in the **Selected artifacts** list, and select **Move up**, **Move down**, **Move to top**, or **Move to bottom**. |
38 |
| - - To edit the artifact's parameters, select **Edit** to reopen the **Add artifact** pane. |
39 |
| - - To delete the artifact from the **Selected artifacts** list, select **Delete**. |
| 57 | + - To delete an artifact from the **Selected artifacts** list, select **...** and then select **Delete**. |
40 | 58 |
|
41 |
| -1. When you're done adding and arranging artifacts, select **OK**. |
42 |
| -1. The **Create lab resource** screen shows the number of artifacts added. To add, edit, rearrange, or delete the artifacts before you create the VM, select **Add or Remove Artifacts** again. |
| 59 | +1. When you're done adding, arranging, and configuring artifacts, select **OK** on the **Add artifacts** page. |
| 60 | +1. The **Artifacts** section of the **Create lab resource** screen shows the number of artifacts added. To add, edit, rearrange, or delete the artifacts before you create the VM, select **Add or Remove Artifacts** again. |
| 61 | +1. Optionally configure any **Advanced Settings** or **Tags**, and then select **Create** and **Create** again at the bottom of the screen to create the VM with added artifacts. |
43 | 62 |
|
44 | 63 | After you create the VM, the installed artifacts appear on the VM's **Artifacts** page. To see details about each artifact's installation, select the artifact name.
|
45 | 64 |
|
46 |
| -To install artifacts on an existing VM: |
| 65 | +### Add artifacts to an existing VM |
47 | 66 |
|
48 | 67 | 1. From the lab's home page, select the VM from the **My virtual machines** list.
|
49 |
| -1. On the VM page, select **Artifacts** in the top menu bar or left navigation. |
| 68 | +1. On the VM page, select **Artifacts** in the top menu bar or under **Operations** in the left navigation. |
50 | 69 | 1. On the **Artifacts** page, select **Apply artifacts**.
|
51 | 70 |
|
52 |
| - :::image type="content" source="./media/add-artifact-vm/artifacts.png" alt-text="Screenshot that shows Artifacts pane for an existing V M."::: |
| 71 | + :::image type="content" source="./media/add-artifact-vm/artifacts.png" alt-text="Screenshot that shows the Artifacts pane for an existing VM."::: |
53 | 72 |
|
54 |
| -1. On the **Add artifacts** page, select and configure artifacts the same as for a new VM. |
| 73 | +1. On the **Add artifacts** page, select and configure artifacts the same way as for a new VM. |
55 | 74 | 1. When you're done adding artifacts, select **Install**. The artifacts install on the VM immediately.
|
56 | 75 |
|
57 |
| -## Add artifacts to VMs by using Azure PowerShell |
| 76 | +# [Azure PowerShell](#tab/PowerShell) |
58 | 77 |
|
59 |
| -[!INCLUDE [updated-for-az](~/reusable-content/ce-skilling/azure/includes/updated-for-az.md)] |
| 78 | +If necessary, sign in to your Azure account by using the [Connect-AzAccount](/powershell/module/Az.Accounts/Connect-AzAccount) cmdlet. If you have multiple Azure subscriptions, use `Set-AzContext -SubscriptionId "<SubscriptionId>"` and provide the subscription ID you want to use. |
60 | 79 |
|
61 |
| -The following PowerShell script applies an artifact to a VM by using the [Invoke-AzResourceAction](/powershell/module/az.resources/invoke-azresourceaction) cmdlet. |
| 80 | +Run the following PowerShell script to apply an artifact to a VM by using the [Invoke-AzResourceAction](/powershell/module/az.resources/invoke-azresourceaction) cmdlet. Provide the information the script calls for when prompted. |
62 | 81 |
|
63 | 82 | ```powershell
|
64 |
| -#Requires -Module Az.Resources |
65 |
| -
|
66 |
| -param |
67 |
| -( |
| 83 | +param ( |
68 | 84 | [Parameter(Mandatory=$true, HelpMessage="The ID of the subscription that contains the lab")]
|
69 | 85 | [string] $SubscriptionId,
|
70 | 86 | [Parameter(Mandatory=$true, HelpMessage="The name of the lab that has the VM")]
|
@@ -107,15 +123,12 @@ $template = Get-AzResource -ResourceGroupName $resourceGroupName `
|
107 | 123 | if ($template -eq $null) { throw "Unable to find template $ArtifactName in lab $DevTestLabName." }
|
108 | 124 |
|
109 | 125 | # Find the VM in Azure
|
110 |
| -$FullVMId = "/subscriptions/$SubscriptionId/resourceGroups/$resourceGroupName` |
111 |
| - /providers/Microsoft.DevTestLab/labs/$DevTestLabName/virtualmachines/$virtualMachineName" |
| 126 | +$FullVMId = "/subscriptions/$SubscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.DevTestLab/labs/$DevTestLabName/virtualmachines/$virtualMachineName" |
112 | 127 |
|
113 | 128 | $virtualMachine = Get-AzResource -ResourceId $FullVMId
|
114 | 129 |
|
115 | 130 | # Generate the artifact id
|
116 |
| -$FullArtifactId = "/subscriptions/$SubscriptionId/resourceGroups/$resourceGroupName` |
117 |
| - /providers/Microsoft.DevTestLab/labs/$DevTestLabName/artifactSources/$($repository.Name)` |
118 |
| - /artifacts/$($template.Name)" |
| 131 | +$FullArtifactId = "/subscriptions/$SubscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.DevTestLab/labs/$DevTestLabName/artifactSources/$($repository.Name)/artifacts/$($template.Name)" |
119 | 132 |
|
120 | 133 | # Handle the input parameters to pass through
|
121 | 134 | $artifactParameters = @()
|
@@ -153,10 +166,11 @@ if ($virtualMachine -ne $null) {
|
153 | 166 | } else {
|
154 | 167 | Write-Error "##[error]$VirtualMachine was not found in the DevTest Lab, unable to apply the artifact"
|
155 | 168 | }
|
156 |
| -
|
157 | 169 | ```
|
158 | 170 |
|
159 |
| -## Next steps |
| 171 | +--- |
| 172 | + |
| 173 | +## Related content |
160 | 174 |
|
161 | 175 | - [Specify mandatory artifacts](devtest-lab-mandatory-artifacts.md)
|
162 | 176 | - [Create custom artifacts](devtest-lab-artifact-author.md)
|
|
0 commit comments