|
| 1 | +--- |
| 2 | +title: 'Reference: imagedefinition.yaml and task.yaml files' |
| 3 | +description: Reference for customizing Dev Box environments using devbox.yaml and task.yaml files, including built-in tasks and parameters. |
| 4 | +author: RoseHJM |
| 5 | +ms.service: dev-box |
| 6 | +ms.topic: reference |
| 7 | +ms.date: 05/09/2025 |
| 8 | +ms.author: rosemalcolm |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +# Reference: imagedefinition.yaml files |
| 13 | + |
| 14 | +A Dev Box yaml allows you to define customization tasks that ought to run during Dev Box creation. A devbox.yaml file might live in the same repository as the primary source code being used by the dev team, or in a centralized repository of configurations. |
| 15 | + |
| 16 | +Example Image Definition yaml: |
| 17 | + |
| 18 | +``` |
| 19 | +$schema: 1.0 |
| 20 | +name: project-sample-1 |
| 21 | +image: MicrosoftWindowsDesktop_windows-ent-cpc_win11-21h2-ent-cpc-m365 |
| 22 | +tasks: |
| 23 | +- task: "powershell" |
| 24 | + inputs: |
| 25 | + command: |
| 26 | +``` |
| 27 | + |
| 28 | +**name** |
| 29 | + |
| 30 | +**Required** |
| 31 | + |
| 32 | +A friendly name for the image definition associated with this devbox.yaml. This setting controls the name of the image definition available when creating and updating pools. |
| 33 | + |
| 34 | +``` |
| 35 | +name: myVSDevBox |
| 36 | +``` |
| 37 | + |
| 38 | +**image** |
| 39 | + |
| 40 | +**Required** |
| 41 | + |
| 42 | +The image you would like to use as the base image for your image definition. This image can be a marketplace image: |
| 43 | + |
| 44 | +``` |
| 45 | +image: MicrosoftWindowsDesktop_windows-ent-cpc_win11-21h2-ent-cpc-m365 |
| 46 | +``` |
| 47 | + |
| 48 | +Or a custom image: |
| 49 | + |
| 50 | +``` |
| 51 | +image: galleryname/imagename@version |
| 52 | +``` |
| 53 | + |
| 54 | +To get a list of images that your DevCenter has access to, use this az cli command: |
| 55 | + |
| 56 | +``` |
| 57 | +az devcenter admin image list --dev-center-name CustomizationsImagingHQ --resource-group TeamCustomizationsImagingRG --query "[].name" |
| 58 | +``` |
| 59 | + |
| 60 | +You would need the DevCenter az cli extension: |
| 61 | + |
| 62 | +``` |
| 63 | +az extension add --name devcenter |
| 64 | +``` |
| 65 | + |
| 66 | +**tasks** |
| 67 | + |
| 68 | +**Required** |
| 69 | + |
| 70 | +An object collection of Dev Box customization tasks to be executed when provisioning a Dev Box. The specific inputs provided to a task vary by task. |
| 71 | + |
| 72 | +Example: |
| 73 | + |
| 74 | +``` |
| 75 | +tasks: |
| 76 | +- name: winget |
| 77 | + parameters: |
| 78 | + package: GitHub.GitHubDesktop |
| 79 | +``` |
| 80 | + |
| 81 | +The **timeout** parameter is supported by all tasks and is optional. |
| 82 | + |
| 83 | +Example: |
| 84 | + |
| 85 | +``` |
| 86 | +tasks: |
| 87 | +- name: powershell |
| 88 | + parameters: |
| 89 | + command: <command> |
| 90 | + timeout: 1800 # in seconds |
| 91 | +``` |
| 92 | + |
| 93 | +**Built-in tasks** |
| 94 | + |
| 95 | +PowerShell and Winget are available as built-in tasks and can be invoked directly without attaching a DevCenter-level catalog that defines the implementation of these tasks. |
| 96 | + |
| 97 | +**Winget built-in task** |
| 98 | + |
| 99 | +Applies a winget configuration to the Dev Box. |
| 100 | + |
| 101 | +**Parameters:** |
| 102 | + |
| 103 | +- **configurationFile** |
| 104 | + - type: "string" |
| 105 | + - The path to the winget config yaml file. The file must be located in the local machine. |
| 106 | + - required: false |
| 107 | + |
| 108 | +- **downloadUrl** |
| 109 | + - type: "string" |
| 110 | + - A publicly accessible URL where the config yaml file is stored. The file is downloaded to the path given in 'configurationFile'. |
| 111 | + - required: false |
| 112 | + |
| 113 | +- **inlineConfigurationBase64** |
| 114 | + - type: "string" |
| 115 | + - A base64 encoded string of the winget config yaml file. The file is decoded to the path given in 'configurationFile' or to a temporary file if not specified. |
| 116 | + - required: false |
| 117 | + |
| 118 | +- **package** |
| 119 | + - type: "string" |
| 120 | + - The name of the package to install. |
| 121 | + - If a config yaml file is provided under other parameters, there's no need for the package name. |
| 122 | + - required: false |
| 123 | + |
| 124 | +- **version** |
| 125 | + - type: "string" |
| 126 | + - The version of the package to install. |
| 127 | + - If a config yaml file is provided under other parameters, there's no need for the package version. |
| 128 | + - required: false |
| 129 | + |
| 130 | +**Powershell built-in task** |
| 131 | + |
| 132 | +Execute a PowerShell command. |
| 133 | + |
| 134 | +**Parameters:** |
| 135 | + |
| 136 | +- **command** |
| 137 | + - type: "string" |
| 138 | + - The command to execute. |
| 139 | + - required: true |
| 140 | + |
| 141 | +## Reference: task.yaml files |
| 142 | + |
| 143 | +**task.yaml** |
| 144 | + |
| 145 | +Customization tasks are reusable units of installation code or environment configuration – written using PowerShell scripts and described using a task.yaml metadata file. These tasks are then used by devs to customize a dev box by referencing them from a devbox.yaml file. |
| 146 | + |
| 147 | +By defining customization tasks, you can define a guardrailed palette of what tasks are available to your developers for use in devbox.yamls, without providing high-privilege actions such as the ability to run any PowerShell command. |
| 148 | + |
| 149 | +Example of a task definition that executes a PowerShell command in a specific working directory: |
| 150 | + |
| 151 | +``` |
| 152 | +name: powershell |
| 153 | +description: Execute a powershell command |
| 154 | +author: Microsoft Corporation |
| 155 | +command: ".\runcommand.ps1 -command {{command}} -workingDirectory {{workingDirectory}}" |
| 156 | +inputs: |
| 157 | + command: |
| 158 | + type: string |
| 159 | + defaultValue: "" |
| 160 | + required: true |
| 161 | + description: The command to execute |
| 162 | + workingDirectory: |
| 163 | + type: string |
| 164 | + defaultValue: "" |
| 165 | + required: false |
| 166 | + description: The working directory to execute the command in |
| 167 | +``` |
| 168 | + |
| 169 | +**Attributes:** |
| 170 | + |
| 171 | +- **name** |
| 172 | + **Required** |
| 173 | + The unique identifier used to refer to a task from devbox.yaml. The name should be unique in the context of the catalog where the task exists. |
| 174 | + Naming must match existing Azure Resource constraints: The name must be between 3 and 63 characters and must start with an alphanumeric character and consist of only alphanumeric characters and '-', '.', or '_'. The "/" character is reserved. |
| 175 | + |
| 176 | + ``` |
| 177 | + name: powershell |
| 178 | + ``` |
| 179 | + |
| 180 | +- **description** |
| 181 | + **Optional** |
| 182 | + Description of the task. |
| 183 | + |
| 184 | + ``` |
| 185 | + description: This task executes a powershell command |
| 186 | + ``` |
| 187 | + |
| 188 | +- **inputs** |
| 189 | + **Required** |
| 190 | + List of parameters that this task takes as an input from a devbox.yaml and utilizes while executing the command. Each parent item represents the name of a parameter and supports these keys: |
| 191 | + |
| 192 | + - **type** [required]: input data type for this parameter. Can be string, int. |
| 193 | + - **defaultValue** [required]: default value this parameter takes. |
| 194 | + - **required** [required]: specifies whether this parameter is optional or required. |
| 195 | + - **description** [required]: a description of what this parameter represents. |
| 196 | + |
| 197 | + ``` |
| 198 | + inputs: |
| 199 | + command: |
| 200 | + type: string |
| 201 | + defaultValue: "" |
| 202 | + required: true |
| 203 | + description: The command to execute |
| 204 | + ``` |
| 205 | + |
| 206 | +- **command** |
| 207 | + **Required** |
| 208 | + The command to execute to fulfill this task. The provided command string would be executed in Windows PowerShell on the local machine. |
| 209 | + |
| 210 | + ``` |
| 211 | + command: ".\runcommand.ps1 |
| 212 | + ``` |
| 213 | + |
| 214 | +- **Referencing Variables in command** |
| 215 | + To reference parameters in a command, you can specify the variable name in Handlebar style double braces {{parameter_name}}. The values of these variables are interpolated before your command is executed. |
| 216 | + |
| 217 | + ``` |
| 218 | + command: ".\runcommand.ps1 -command {{command}} -workingDirectory {{workingDirectory}}" |
| 219 | + ``` |
| 220 | + |
| 221 | +- **timeout** |
| 222 | + **Optional** |
| 223 | + The maximum amount of time (in minutes) to wait for task execution to complete, before timing out the task. Defaults to 30 minutes. |
| 224 | + |
| 225 | + ``` |
| 226 | + timeout: 30 |
| 227 | + ``` |
| 228 | + |
| 229 | +- **author** |
| 230 | + **Optional** |
| 231 | + Identifier of a task author – to help with audits and troubleshooting. |
| 232 | + |
| 233 | + ``` |
| 234 | + author: Contoso Corporation |
| 235 | + ``` |
| 236 | + |
| 237 | +- **documentationURL** |
| 238 | + **Optional** |
| 239 | + Link to documentation for this task. |
| 240 | + |
| 241 | + ``` |
| 242 | + documentationURL: "https://link.to/documentation" |
| 243 | + ``` |
| 244 | + |
| 245 | +- **licenseURL** |
| 246 | + **Optional** |
| 247 | + Link to the license for this task. |
| 248 | + |
| 249 | + ``` |
| 250 | + licenseURL: "https://link.to/license" |
| 251 | + ``` |
0 commit comments