Skip to content

Commit beada7c

Browse files
committed
Updates from Doc-kit
1 parent db24999 commit beada7c

1 file changed

Lines changed: 53 additions & 21 deletions

File tree

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

Lines changed: 53 additions & 21 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,13 +18,37 @@ 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, authenticate securely. To avoid exposing sensitive information, 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.
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

@@ -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>"
@@ -83,19 +110,21 @@ tasks:
83110
pat: "{{https://contoso-vault.vault.azure.net/secrets/github-pat}}"
84111
```
85112

86-
Or, you can reference the secret in-line with a built-in task, as shown in the following example:
113+
Or, you can reference the secret directly in the `pat` parameter, as shown in the following example:
87114

88115
```yaml
89-
$schema: "1.0"
116+
$schema: "1.0"
90117
name: "example-image-definition"
91118
image: microsoftvisualstudio_visualstudioplustools_vs-2022-ent-general-win11-m365-gen2
92-
description: "Clones a public example Git repository"
119+
description: "Clones a private repository by using a PAT stored in Azure Key Vault"
93120
94-
tasks:
95-
- name: git-clone
96-
description: Clone this repository into C:\Workspaces
97-
parameters:
98-
command: MyCommand –MyParam "{{KEY_VAULT_SECRET_URI}}"
121+
tasks:
122+
- name: git-clone
123+
description: Clone this repository into C:\workspaces
124+
parameters:
125+
repositoryUrl: https://dev.azure.com/<org>/<project>/_git/<repo>
126+
directory: C:\workspaces
127+
pat: "{{https://<key-vault-name>.vault.azure.net/secrets/<secret-name>}}"
99128
```
100129

101130

@@ -120,9 +149,9 @@ The Dev Box Visual Studio Code extension and Dev Box CLI don't support hydrating
120149

121150
## Authenticate to Azure resources by using service principals
122151

123-
By using service principals, you can 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 by using the existing secrets feature.
152+
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.
124153

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.
154+
1. Create a service principal in Microsoft Entra ID, and assign it the necessary roles for the resources you want to use.
126155

127156
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.
128157

@@ -146,15 +175,17 @@ By using service principals, you can securely authenticate to Azure resources wi
146175
Now you can authenticate in customization tasks by hydrating the service principal password from the Key Vault at customization time.
147176

148177
### Example: Download a file from Azure Storage
178+
149179
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:
150180

151181
1. Installs the Azure CLI by using the winget package manager.
152182

153183
1. Runs a PowerShell script that:
154-
- Authenticates to Azure by using a service principal, with the password securely retrieved from Azure Key Vault.
155-
- Downloads a blob (file) from an Azure Storage account by using the authenticated session.
156184

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.
185+
- Authenticates to Azure by using a service principal, with the password retrieved from Azure Key Vault.
186+
- Downloads a blob (file) from an Azure Storage account by using the authenticated session.
187+
188+
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.
158189

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

183214
### Example: Download an artifact from Azure DevOps
215+
184216
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.
185217

186218
After you configure these steps, use the service principal credentials in customization tasks to authenticate and download artifacts securely from Azure DevOps.
@@ -196,10 +228,10 @@ To add a service principal to your Azure DevOps organization:
196228

197229
:::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":::
198230

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.
231+
- **Users**: Enter the service principal's Application ID (appId) as the user email.
232+
- **Access Level**: Select **Basic**.
233+
- **Add to project**: Select the project where you want to add the service principal.
234+
- **Azure DevOps groups**: Assign the service principal to the **Readers** group.
203235

204236
1. Complete the process to grant the necessary permissions.
205237

0 commit comments

Comments
 (0)