Skip to content

Commit e6cf3e8

Browse files
Merge pull request #312148 from RoseHJM/mdb-mask-secrets
MDB - mask secrets
2 parents 35e452d + df372f7 commit e6cf3e8

1 file changed

Lines changed: 49 additions & 19 deletions

File tree

articles/dev-box/how-to-customizations-connect-resource-repository.md

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
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.
44
#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.
55
author: RoseHJM
66
ms.author: rosemalcolm
@@ -18,21 +18,45 @@ ms.date: 02/06/2026
1818

1919
# Securely connect to Azure resources or clone private repositories
2020

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.
2243

2344
## Use key vault secrets in customization files
2445

2546
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.
2647

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.
2852

2953
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.
3054

3155
### Configure key vault access for customizations
3256

3357
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.
3458

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.
3660

3761
The following screenshot shows the option to allow trusted Microsoft services to bypass the firewall in Azure Key Vault settings.
3862

@@ -49,7 +73,10 @@ To configure key vault secrets for user customizations, also:
4973

5074
### Team customizations example
5175

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).
5380
5481
```yaml
5582
$schema: "<SCHEMA_VERSION>"
@@ -101,7 +128,7 @@ tasks:
101128

102129
### User customizations example
103130

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.
105132

106133
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.
107134

@@ -118,11 +145,11 @@ tasks:
118145

119146
The Dev Box Visual Studio Code extension and Dev Box CLI don't support hydrating secrets in the inner-loop testing workflow for customizations.
120147

121-
## Authenticate to Azure resources with service principals
148+
## Authenticate to Azure resources by using service principals
122149

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.
124151

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.
126153

127154
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.
128155

@@ -139,22 +166,24 @@ Service principals let you securely authenticate to Azure resources without expo
139166
}
140167
```
141168

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`
143170

144171
1. On the Key Vault, grant the *Key Vault Secrets User* role to the project identity.
145172

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.
147174

148175
### Example: Download a file from Azure Storage
176+
149177
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:
150178

151-
1. Installs the Azure CLI using the winget package manager.
179+
1. Installs the Azure CLI by using the winget package manager.
152180

153181
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.
156182

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.
158187

159188
```yaml
160189
$schema: "1.0"
@@ -181,6 +210,7 @@ The following example shows how to download a file from a storage account. The Y
181210
This setup lets you automate secure use of Azure resources during Dev Box provisioning without exposing credentials in the script.
182211

183212
### Example: Download an artifact from Azure DevOps
213+
184214
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.
185215

186216
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:
196226

197227
:::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":::
198228

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.
203233

204234
1. Complete the process to grant the necessary permissions.
205235

0 commit comments

Comments
 (0)