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
title: Use key vault secrets in customization files
3
-
description: Learn how to use Azure Key Vault secrets in team and user customization files to clone private repositories.
2
+
title: Fetch Azure Key Vault Secrets from Dev Box Customizations Files
3
+
description: Discover how to fetch Azure Key Vault secrets by using team and user customization files to enhance security and simplify workflows.
4
+
#customer intent: As a platform engineer, I want to configure Azure Key Vault secrets so that my development teams can securely access private repositories during Dev Box customization.
4
5
author: RoseHJM
5
6
ms.author: rosemalcolm
6
7
ms.service: dev-box
7
8
ms.custom:
8
9
- ignite-2024
10
+
- ai-gen-docs-bap
11
+
- ai-gen-title
12
+
- ai-seo-date:05/10/2025
13
+
- ai-gen-description
9
14
ms.topic: how-to
10
-
ms.date: 04/20/2025
11
-
12
-
#customer intent: As a Dev Center Admin or Project Admin, I want to create image definition files so that my development teams can create customized dev boxes.
15
+
ms.date: 05/10/2025
13
16
---
14
17
15
-
# Clone a private repository by using a customization file
18
+
# Use Azure Key Vault secrets in customization files
You can use secrets from your Azure key vault in your YAML customizations to clone private repositories, or with any custom task you author that requires an access token. In a team customization file, you can use a personal access token (PAT) stored in a key vault to access a private repository.
23
+
You can use secrets from your Azure key vault in your YAML customizations to clone private repositories, or with any task you author that requires an access token. For example, in a team customization file, you can use a personal access token (PAT) stored in a key vault to access a private repository.
24
+
25
+
## Use key vault secrets in customization files
21
26
22
-
## Use key vault secrets in team customization files
27
+
To use a secret, like a PAT, in your customization files, store your PAT as a key vault secret.
23
28
24
-
To clone a private repository, store your PAT as a key vault secret. See [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), and use it when you invoke the `git-clone` task in your customization.
29
+
Both team and user customizations support fetching secrets from a key vault. Team customizations, also known as image definition files, define the base image for the dev box with the`image` parameter, and list the tasks that run when a dev box is created. User customizations list the tasks that run when a dev box is created. The following examples show how to use a key vault secret in both types of customizations.
25
30
26
-
To configure your key vault secrets for use in your YAML customizations:
31
+
To configure key vault secrets for use in your YAML customizations:
27
32
28
33
1. Ensure that your dev center project's managed identity has the Key Vault Reader role and the Key Vault Secrets User role on your key vault.
29
34
2. Grant the Key Vault Secrets User role for the key vault secret to each user or user group that 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, the admin's user account, and any user or group that needs the secret during dev box customization.
30
35
31
-
For more information, see:
36
+
You can use a key vault secret in-line with the built-in PowerShell task:
32
37
33
-
-[Configure a managed identity for a dev center](../deployment-environments/how-to-configure-managed-identity.md#configure-a-managed-identity-for-a-dev-center)
34
-
-[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)
This example shows an image definition file. The `KEY_VAULT_SECRET_URI` is the URI of the secret in your key vault.
35
48
36
49
You can reference the secret in your YAML customization in the following format, which uses the `git-clone` task as an example:
37
50
@@ -45,37 +58,34 @@ tasks:
45
58
directory: C:\Workspaces
46
59
pat: '{{KEY_VAULT_SECRET_URI}}'
47
60
```
61
+
This example shows a user customization file. There is no `image` specified.
48
62
49
-
## Use key vault secrets in user customization files
50
-
51
-
To clone a private Azure Repos repository from a user customization file, you don't need to configure a secret in Azure Key Vault. If you want to clone a private Azure Repos repository from a user customization file, you don't need to configure a secret in Azure Key Vault. Instead, you can use `{{ado}}` or `{{ado://your-ado-organization-name}}` as a parameter. This parameter fetches an access token on your behalf when you're creating a dev box. The access token has read-only permission to your repository.
52
-
53
-
The `git-clone` task in the quickstart catalog uses the access token to clone your repository. Here's an example:
63
+
User customizations let you obtain an Azure DevOps token to clone private repositories without explicitly specifying a PAT from the key vault. The service automatically exchanges your Azure token for an Azure DevOps token at run time.
54
64
55
65
```yml
56
-
tasks:
57
-
- name: git-clone
58
-
description: Clone this repository into C:\Workspaces
The dev center needs access to your key vault. Dev centers don't support service tags, so if your key vault is private, allow trusted Microsoft services to bypass the firewall.
76
+
The Dev Box VS Code extension and Dev Box CLI don't support hydrating secrets in the inner-loop testing workflow for customizations.
66
77
67
-
Dev centers don't support service tags, so if the key vault is private, allow trusted Microsoft services to bypass the firewall.
78
+
## Configure key vault access
68
79
69
-
:::image type="content" source="media/how-to-use-secrets-customization-files/trusted-services-bypass-firewall.png" alt-text="Screenshot that shows the option to allow trusted Microsoft services to bypass the firewall in Azure Key Vault settings." lightbox="media/how-to-use-secrets-customization-files/trusted-services-bypass-firewall.png":::
80
+
The dev center needs access to your key vault. Because dev centers don't support service tags, if your key vault is private, let trusted Microsoft servicesbypass the firewall.
70
81
71
-
To learn howto allow trusted Microsoft services to bypass the firewall, see [Configure Azure Key Vault networking settings](/azure/key-vault/general/how-to-azure-key-vault-network-security).
82
+
:::image type="content" source="media/how-to-use-secrets-customization-files/trusted-services-bypass-firewall.png" alt-text="Screenshot that shows the option to allow trusted Microsoft services to bypass the firewall in Azure Key Vault settings." lightbox="media/how-to-use-secrets-customization-files/trusted-services-bypass-firewall.png":::
72
83
73
-
## Share a customization file from a code repository
84
+
To learn how to let trusted Microsoft services bypass the firewall, see [Configure Azure Key Vault networking settings](/azure/key-vault/general/how-to-azure-key-vault-network-security).
74
85
75
-
Make the customization file available to dev box pools by naming it *imagedefinition.yaml* and uploading it to the repository that hosts the catalog. When you create a dev box pool, you can select the customization file from the catalog to apply to the dev boxes in the pool.
76
86
77
87
## Related content
78
88
79
89
- [Microsoft Dev Box team customizations](concept-what-are-team-customizations.md)
80
90
- [Configure imaging for Dev Box team customizations](how-to-configure-customization-imaging.md)
81
-
- [Add and configure a catalog from GitHub or Azure Repos](../deployment-environments/how-to-configure-catalog.md)
91
+
- Learn how to [add and configure a catalog from GitHub or Azure Repos](../deployment-environments/how-to-configure-catalog.md).
0 commit comments