Skip to content

Commit d172e7a

Browse files
authored
Merge pull request #272411 from RoseHJM/MDB-customizations-secrets
MDB - Add customizations secrets section
2 parents bcb4d86 + 098e535 commit d172e7a

File tree

2 files changed

+56
-11
lines changed

2 files changed

+56
-11
lines changed

articles/dev-box/how-to-customize-dev-box-setup-tasks.md

Lines changed: 56 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,35 @@ You can implement customizations in stages, building from a simple but functiona
2727
1. [Create a customized dev box by using an example configuration file](#create-a-customized-dev-box-by-using-an-example-configuration-file)
2828
1. [Write a configuration file](#write-a-configuration-file)
2929
1. [Share a configuration file from a code repository](#share-a-configuration-file-from-a-code-repository)
30-
1. [Define new tasks in a catalog](#define-new-tasks-in-a-catalog)
30+
1. [Define new tasks in a catalog](#define-new-tasks-in-a-catalog)
31+
1. [Use secrets from an Azure Key Vault](#use-secrets-from-an-azure-key-vault)
3132

3233
> [!IMPORTANT]
3334
> Customizations in Microsoft Dev Box are currently in PREVIEW.
3435
> See the [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/) for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
3536
3637
### Team-specific customization scenarios
3738

38-
Customizations are useful wherever you need to configure settings, install software, add extensions, or set common OS settings like enabling Windows Features on your dev boxes during the final stage of creation. Development team leads can use customizations to preconfigure the software required for their specific development team. Developer team leads can author configuration files that apply only the setup tasks relevant for their teams. This method lets developers make their own dev boxes that best fit their work, without needing to ask IT for changes or wait for the engineering team to create a custom VM image.
39+
Customizations are useful wherever you need to configure settings or install software. You can also use customizations to add extensions, or to set common OS settings like enabling Windows Features on your dev boxes during the final stage of creation. Development team leads can use customizations to preconfigure the software required for their specific development team. Developer team leads can author configuration files that apply only the setup tasks relevant for their teams. This method lets developers make their own dev boxes that best fit their work, without needing to ask IT for changes or wait for the engineering team to create a custom VM image.
3940

4041
### What are tasks?
4142

42-
A task performs a specific action, like installing software. Each task consists of one or more PowerShell scripts, along with a *task.yaml* file that provides parameters and defines how the scripts run. You can also include a PowerShell command in the task.yaml file. You can store a collection of curated setup tasks in a catalog attached to your dev center, with each task in a separate folder. Dev Box supports using a GitHub repository or an Azure DevOps repository as a catalog, and scans a specified folder of the catalog recursively to find task definitions.
43+
A task performs a specific action, like installing software. Each task consists of one or more PowerShell scripts, along with a *task.yaml* file that provides parameters and defines how the scripts run. You can also include a PowerShell command in the task.yaml file. You can store a collection of curated setup tasks in a catalog attached to your dev center, with each task in a separate folder. Dev Box supports using a GitHub repository or an Azure Repos repository as a catalog, and scans a specified folder of the catalog recursively to find task definitions.
4344

4445
Microsoft provides a quick start catalog to help you get started with customizations. It includes a default set of tasks that define common setup tasks:
4546

46-
- Installing software with the WinGet or Chocolatey package managers
47-
- Cloning a repository by using git-clone
48-
- Configuring applications like installing Visual Studio extensions
49-
- Running PowerShell scripts
47+
- Install software with the WinGet or Chocolatey package managers
48+
- Clone a repository by using git-clone
49+
- Configure applications like installing Visual Studio extensions
50+
- Run PowerShell scripts
5051

51-
The following example shows a catalog with choco, git-clone, install-vs-extension, and PowerShell tasks defined. Notice that each folder contains a task.yaml file and at least one PowerShell script. Task.yaml files cache scripts and the input parameters needed to reference them from configuration files.
52+
The following example shows a catalog with choco, git-clone, install-vs-extension, and PowerShell tasks defined. Each folder contains a task.yaml file and at least one PowerShell script. Task.yaml files cache scripts and the input parameters needed to reference them from configuration files.
5253

5354
:::image type="content" source="media/how-to-customize-dev-box-setup-tasks/customizations-catalog-tasks.png" alt-text="Screenshot showing a catalog with choco, git-clone, install-vs-extension, and PowerShell tasks defined, with a tasks.yaml for each task." lightbox="media/how-to-customize-dev-box-setup-tasks/customizations-catalog-tasks.png":::
5455

5556
### What is a configuration file?
5657

57-
Dev Box customizations use a yaml formatted file to specify a list of tasks to apply from the catalog when creating a new dev box. These configuration files include one or more 'tasks', which identify the catalog task and provide parameters like the name of the software to install. The configuration file is then made available to the developers creating new dev boxes. The following example uses a winget task to install Visual Studio Code, and a `git clone` task to clone a repository.
58+
Dev Box customizations use a yaml formatted file to specify a list of tasks to apply from the catalog when creating a new dev box. These configuration files include one or more *tasks*, which identify the catalog task and provide parameters like the name of the software to install. The configuration file is then made available to the developers creating new dev boxes. The following example uses a winget task to install Visual Studio Code, and a `git clone` task to clone a repository.
5859

5960
```yaml
6061
# From https://github.com/microsoft/devcenter-examples
@@ -107,7 +108,7 @@ To attach the quick start catalog to the dev center:
107108
108109
### Create your customized dev box
109110
110-
Now you have a catalog that defines the tasks your developers can use, you can reference those tasks from a configuration file and create a customized dev box.
111+
Now you have a catalog that defines the tasks your developers can use. You can reference those tasks from a configuration file and create a customized dev box.
111112
112113
1. Download an [example yaml configuration from the samples repository](https://aka.ms/devbox/customizations/samplefile). This example configuration installs Visual Studio Code, and clones the OrchardCore .NET web app repo to your dev box.
113114
1. Sign in to the [Microsoft Dev Box developer portal](https://aka.ms/devbox-portal).
@@ -159,7 +160,7 @@ Before you can create and test your own configuration file, there must be a cata
159160
Make your configuration file seamlessly available to your developers by naming it *workload.yaml* and uploading it to a repository accessible to the developers, usually their coding repository. When you create a dev box, you specify the repository URL and the configuration file is cloned along with the rest of the repository. Dev box searches the repository for a file named workload.yaml and, if one is located, performs the tasks listed. This configuration provides a seamless way to perform customizations on a dev box.
160161
161162
1. Create a configuration file named *workload.yaml*.
162-
1. Add the configuration file to the root of a private Azure DevOps repository with your code and commit it.
163+
1. Add the configuration file to the root of a private Azure Repos repository with your code and commit it.
163164
1. Sign in to the [Microsoft Dev Box developer portal](https://aka.ms/devbox-portal).
164165
1. Select **New** > **Dev Box**.
165166
1. In **Add a dev box**, enter the following values:
@@ -193,6 +194,50 @@ Creating new tasks in a catalog allows you to create customizations tailored to
193194
194195
1. Create a configuration file for those tasks by following the steps in [Write a configuration file](#write-a-configuration-file).
195196
197+
## Use secrets from an Azure Key Vault
198+
199+
You can use secrets from your Azure Key Vault in your yaml configurations to clone private repositories, or with any custom task you author that requires an access token.
200+
201+
To configure your Key Vault secrets for use in your yaml configurations,
202+
203+
1. Ensure that your dev center project’s managed identity has the Key Vault Reader role and Key Vault Secrets User role on your key vault.
204+
205+
1. Grant the Secrets User role for the Key Vault secret to each user or user group who should be able to consume the secret during the customization of a dev box. The user or group granted the role must include the managed identity for the dev center, your own user account, and any user or group who needs the secret during the customization of a dev box.
206+
207+
For more information, see:
208+
- Learn how to [Configure a managed identity for a dev center](../deployment-environments/how-to-configure-managed-identity.md#configure-a-managed-identity-for-a-dev-center).
209+
- Learn how to [Grant the managed identity access to the key vault secret](../deployment-environments/how-to-configure-managed-identity.md#grant-the-managed-identity-access-to-the-key-vault-secret).
210+
211+
212+
You can reference the secret in your yaml configuration in the following format, using the git-clone task as an example:
213+
214+
```yml
215+
$schema: "1.0"
216+
tasks:
217+
name: git-clone
218+
description: Clone this repository into C:\Workspaces
219+
parameters:
220+
repositoryUrl: https://myazdo.visualstudio.com/MyProject/_git/myrepo
221+
directory: C:\Workspaces
222+
pat: '{{KEY_VAULT_SECRET_URI}}'
223+
```
224+
225+
If you wish to clone a private Azure DevOps repository (Azure Repos), you don’t need to configure a secret in Key Vault. Instead, you can use `{{ado}}`, or `{{ado://your-ado-organization-name}}` as a parameter. This fetches an access token on your behalf when creating a dev box, which has read-only permission to your repository. The git-clone task in the quickstart catalog uses the access token to clone your repository. Here's an example:
226+
227+
```yml
228+
tasks:
229+
name: git-clone
230+
description: Clone this repository into C:\Workspaces
231+
parameters:
232+
repositoryUrl: https://myazdo.visualstudio.com/MyProject/_git/myrepo
233+
directory: C:\Workspaces
234+
pat: '{{ado://YOUR_ADO_ORG}}'
235+
```
236+
237+
If your organization's policies require you to keep your Key Vault private from the internet, you can set your Key Vault to allow trusted Microsoft services to bypass your firewall rule.
238+
239+
:::image type="content" source="media/how-to-customize-dev-box-setup-tasks/customizations-configure-firewall.png" alt-text="Screenshot showing Azure firewall configuration with Allow trusted Microsoft services to bypass this firewall selected." lightbox="media/how-to-customize-dev-box-setup-tasks/customizations-configure-firewall.png":::
240+
196241
## Related content
197242

198243
- [Add and configure a catalog from GitHub or Azure DevOps](/azure/deployment-environments/how-to-configure-catalog?tabs=DevOpsRepoMSI)
52.9 KB
Loading

0 commit comments

Comments
 (0)