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/dev-box/how-to-customizations-connect-resource-repository.md
+49-19Lines changed: 49 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Use Customizations to Connect to Azure Resources or Clone Private Repositories
3
-
description: Discover how to use fetch Azure Key Vault secrets by using team and user customization files to enhance security and simplify workflows.
3
+
description: Learn how to fetch Azure Key Vault secrets in Dev Box team and user customizations to access private repositories and Azure resources.
4
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.
5
5
author: RoseHJM
6
6
ms.author: rosemalcolm
@@ -18,21 +18,45 @@ ms.date: 02/06/2026
18
18
19
19
# Securely connect to Azure resources or clone private repositories
20
20
21
-
When you access resources like repositories or Azure resources during the customization process, you need to authenticate securely. You can reference Azure Key Vault secrets in your customization files to avoid exposing sensitive information, and you can use service principals to authenticate to Azure for secure resource access. This article explains how to manage and access resources securely during dev box customization.
21
+
When you access resources like repositories or Azure resources during the customization process, authenticate securely. To avoid storing secret values in customization files and source control, reference Azure Key Vault secrets in your customization files. Use service principals to authenticate to Azure for secure resource access. This article explains how to manage and access resources securely during dev box customization.
22
+
23
+
## Prerequisites
24
+
25
+
- A dev center and project configured for Dev Box. If you don't have one, see [Configure Microsoft Dev Box](quickstart-configure-dev-box-service.md).
26
+
- Permission to create a dev box in at least one project. For setup and access, see [Create a dev box](quickstart-create-dev-box.md).
27
+
- Permissions required to configure customizations, Key Vault access, and catalogs. See [Permissions for customizations](concept-what-are-dev-box-customizations.md#permissions-for-customizations).
28
+
- An Azure Key Vault that contains the secrets you want to use.
29
+
- (Service principal examples) Azure CLI installed and signed in, and permission to create service principals. See [Install the Azure CLI](/cli/azure/install-azure-cli).
30
+
31
+
## Security considerations
32
+
33
+
Azure Key Vault integration helps you avoid storing secret values in customization files and source control. However, Dev Box resolves secret placeholders at customization time. Depending on how a task runs and what it writes to output, resolved secret values can appear in task output or logs.
34
+
35
+
> [!IMPORTANT]
36
+
> Don't assume secret values are masked in task output or logs. Validate your customization in a non-production project with non-production secrets.
37
+
38
+
To reduce the chance of exposure:
39
+
40
+
- Prefer identity-based or token-exchange approaches (for example, Azure DevOps token exchange) over long-lived personal access tokens (PATs) when possible.
41
+
- Don't print secrets to output. Avoid verbose or debug modes that can echo credentials, URLs, or headers.
42
+
- Avoid embedding secrets directly in command lines or URLs. If a secret appears in logs, revoke or rotate it and update your key vault.
22
43
23
44
## Use key vault secrets in customization files
24
45
25
46
Use secrets from Azure Key Vault in your YAML customizations to clone private repositories or run tasks that require an access token. For example, in a customization file, use a personal access token (PAT) stored in Azure Key Vault to access a private repository.
26
47
27
-
Both team and user customizations support fetching secrets from a key vault. Team customizations, which use 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.
48
+
Both team and user customizations support fetching secrets from a key vault.
49
+
50
+
-**Team customizations** use image definition files that define the base image for the dev box with the `image` parameter and list the tasks that run when a dev box is created.
51
+
-**User customizations** list the tasks that run when a dev box is created.
28
52
29
53
To use a secret, like a PAT, in your customization files, store it as a key vault secret. The following examples show how to reference a key vault secret in both types of customizations.
30
54
31
55
### Configure key vault access for customizations
32
56
33
57
Your dev center needs access to your key vault. To configure key vault secrets for use in your team or user customizations, make sure the Dev Center project's managed identity has the Key Vault Secrets User role on your key vault.
34
58
35
-
If your organization's policies require you to keep your Key Vault private from the internet, you can create a firewall rule to disable or limit public access. You will need to let trusted Microsoft services bypass the firewall because Dev Center doesn't support service tags. Key vaults with private endpoints or private link integration are not currently supported for this scenario.
59
+
If your organization's policies require you to keep your Key Vault private from the internet, you can create a firewall rule to disable or limit public access. You need to let trusted Microsoft services bypass the firewall because Dev Center doesn't support service tags. Key vaults with private endpoints or private link integration aren't currently supported for this scenario.
36
60
37
61
The following screenshot shows the option to allow trusted Microsoft services to bypass the firewall in Azure Key Vault settings.
38
62
@@ -49,7 +73,10 @@ To configure key vault secrets for user customizations, also:
49
73
50
74
### Team customizations example
51
75
52
-
This syntax uses a key vault secret (PAT) in an image definition file. The `KEY_VAULT_SECRET_URI` is the URI of the secret in your key vault.
76
+
This syntax uses a key vault secret (PAT) in an image definition file. The `KEY_VAULT_SECRET_URI` is the secret identifier (URI) for the secret in your key vault.
77
+
78
+
> [!TIP]
79
+
> Use the versionless secret identifier so Dev Box can fetch the latest version of the secret. For an example, see the "Secret identifier" guidance in [Add and manage catalogs in Microsoft Dev Box](how-to-configure-catalog.md).
53
80
54
81
```yaml
55
82
$schema: "<SCHEMA_VERSION>"
@@ -101,7 +128,7 @@ tasks:
101
128
102
129
### User customizations example
103
130
104
-
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.
131
+
User customizations let you obtain an Azure DevOps token to clone private repositories without explicitly specifying a PAT from the key vault.
105
132
106
133
This example shows the ADO shorthand (`{{ado://...}}`). The service exchanges your Azure token for an Azure DevOps token at runtime, so you don't need to store a PAT in Key Vault.
107
134
@@ -118,11 +145,11 @@ tasks:
118
145
119
146
The Dev Box Visual Studio Code extension and Dev Box CLI don't support hydrating secrets in the inner-loop testing workflow for customizations.
120
147
121
-
## Authenticate to Azure resources with service principals
148
+
## Authenticate to Azure resources by using service principals
122
149
123
-
Service principals let you securely authenticate to Azure resources without exposing user credentials. Create a service principal, assign the required roles, and use it to authenticate in a customization task. Hydrate its password from Key Vault at customization time using the existing secrets feature.
150
+
By using service principals, you can authenticate to Azure resources without using user credentials. Create a service principal, assign the required roles, and use it to authenticate in a customization task. Hydrate its password from Key Vault at customization time by using the existing secrets feature.
124
151
125
-
1. Create a service principal in Azure Active Directory (Azure AD), and assign it the necessary roles for the resources you want to use.
152
+
1. Create a service principal in Microsoft Entra ID, and assign it the necessary roles for the resources you want to use.
126
153
127
154
The output is a JSON object containing the service principal's *appId*, *displayName*, *password*, and *tenant*, which are used for authentication and authorization in Azure Automation scenarios.
128
155
@@ -139,22 +166,24 @@ Service principals let you securely authenticate to Azure resources without expo
139
166
}
140
167
```
141
168
142
-
1. Store the password returned above in a Key Vault secret, like this: `https://mykeyvault.vault.azure.net/secrets/password`
169
+
1. Store the password returned in the previous step in a Key Vault secret, like this: `https://mykeyvault.vault.azure.net/secrets/password`
143
170
144
171
1. On the Key Vault, grant the *Key Vault Secrets User* role to the project identity.
145
172
146
-
Now you can authenticate in customization tasks, hydrating the service principal password from the Key Vault at customization time.
173
+
Now you can authenticate in customization tasks by hydrating the service principal password from the Key Vault at customization time.
147
174
148
175
### Example: Download a file from Azure Storage
176
+
149
177
The following example shows how to download a file from a storage account. The YAML snippet defines a Dev Box customization that performs two main tasks:
150
178
151
-
1. Installs the Azure CLI using the winget package manager.
179
+
1. Installs the Azure CLI by using the winget package manager.
152
180
153
181
1. Runs a PowerShell script that:
154
-
- Logs in to Azure using a service principal, with the password securely retrieved from Azure Key Vault.
155
-
- Downloads a blob (file) from an Azure Storage account using the authenticated session.
156
182
157
-
Example: customization that hydrates a service principal password from Key Vault and uses it to authenticate and download a blob from Azure Storage. Store the service principal password in Key Vault and ensure the project identity has Key Vault Secrets User role.
183
+
- Authenticates to Azure by using a service principal, with the password retrieved from Azure Key Vault.
184
+
- Downloads a blob (file) from an Azure Storage account by using the authenticated session.
185
+
186
+
Example: customization that hydrates a service principal password from Key Vault and uses it to authenticate and download a blob from Azure Storage. Store the service principal password in Key Vault and ensure the project identity has Key Vault Secrets User role.
158
187
159
188
```yaml
160
189
$schema: "1.0"
@@ -181,6 +210,7 @@ The following example shows how to download a file from a storage account. The Y
181
210
This setup lets you automate secure use of Azure resources during Dev Box provisioning without exposing credentials in the script.
182
211
183
212
### Example: Download an artifact from Azure DevOps
213
+
184
214
Download build artifacts from Azure DevOps (ADO) by using a service principal for authentication. Add the service principal's Application ID (appId) as a user in your Azure DevOps organization, then assign the principal to the **Readers** group. This step gives the necessary permissions to use build artifacts.
185
215
186
216
After you configure these steps, use the service principal credentials in customization tasks to authenticate and download artifacts securely from Azure DevOps.
@@ -196,10 +226,10 @@ To add a service principal to your Azure DevOps organization:
196
226
197
227
:::image type="content" source="media/how-to-customizations-connect-resource-repository/dev-box-customizations-devops-add-user.png" alt-text="Screenshot of the Add new users dialog in Azure DevOps, showing fields for user email, access level, project, and group assignment." lightbox="media/how-to-customizations-connect-resource-repository/dev-box-customizations-devops-add-user.png":::
198
228
199
-
-**Users**: Enter the service principal's Application ID (appId) as the user email.
200
-
-**Access Level**: Select **Basic**.
201
-
-**Add to project**: Select the project where you want to add the service principal.
202
-
-**Azure DevOps groups**: Assign the service principal to the **Readers** group.
229
+
-**Users**: Enter the service principal's Application ID (appId) as the user email.
230
+
-**Access Level**: Select **Basic**.
231
+
-**Add to project**: Select the project where you want to add the service principal.
232
+
-**Azure DevOps groups**: Assign the service principal to the **Readers** group.
203
233
204
234
1. Complete the process to grant the necessary permissions.
0 commit comments