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
+80-42Lines changed: 80 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,85 +12,121 @@ ms.custom:
12
12
- ai-seo-date:05/10/2025
13
13
- ai-gen-description
14
14
ms.topic: how-to
15
-
ms.date: 07/22/2025
15
+
ms.date: 09/26/2025
16
16
---
17
17
18
-
# Connect to Azure resources or clone private repositories by using customizations
18
+
# Securely connect to Azure resources or clone private repositories
19
19
20
-
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.
20
+
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
21
22
22
## Use key vault secrets in customization files
23
23
24
-
To use a secret, like a PAT, in your customization files, store your PAT as a key vault secret.
24
+
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.
25
25
26
-
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.
26
+
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.
27
27
28
-
To configure key vault secrets for use in your team or user customizations, ensure that your dev center project's managed identity has the Key Vault Secrets User role on your key vault.
28
+
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.
29
29
30
-
To configure key vault secrets for use in user customizations, you need to additionally:
30
+
### Configure key vault access for customizations
31
31
32
-
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.
33
-
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.
32
+
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
33
35
-
You can use a key vault secret in-line with the built-in task:
34
+
If your key vault is private, let trusted Microsoft services bypass the firewall because Dev Center doesn't yet support service tags.
The following screenshot shows the option to allow trusted Microsoft services to bypass the firewall in Azure Key Vault settings.
37
+
38
+
:::image type="content" source="media/how-to-customizations-connect-resource-repository/trusted-services-bypass-firewall.png" alt-text="Screenshot of the option to allow trusted Microsoft services to bypass the firewall in Azure Key Vault settings." lightbox="media/how-to-customizations-connect-resource-repository/trusted-services-bypass-firewall.png":::
39
+
40
+
To learn more about 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).
41
+
42
+
#### Additional configuration for user customizations
43
+
44
+
To configure key vault secrets for user customizations, also:
45
+
46
+
1. Ensure the Dev Center project's managed identity has both the Key Vault Reader and Key Vault Secrets User roles on your key vault.
47
+
1. Grant the Key Vault Secrets User role for the secret to each user or group who needs it during dev box customization, including the Dev Center managed identity, admin accounts, and any other required users or groups.
48
+
49
+
### Team customizations example
50
+
51
+
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.
52
+
53
+
```yaml
54
+
$schema: "<SCHEMA_VERSION>"
55
+
name: "<IMAGE_DEFINITION_NAME>"
56
+
image: "<BASE_IMAGE>"
57
+
description: "<DESCRIPTION>"
58
+
59
+
tasks:
60
+
- name: <TASK_NAME>
61
+
description: <TASK_DESCRIPTION>
62
+
parameters:
63
+
repositoryUrl: <REPOSITORY_URL>
64
+
directory: <DIRECTORY_PATH>
65
+
pat: "{{<KEY_VAULT_SECRET_URI>}}"
45
66
```
46
-
This example shows an image definition file. The `KEY_VAULT_SECRET_URI` is the URI of the secret in your key vault.
47
67
48
-
You can reference the secret in your YAML customization in the following format, which uses the `git-clone` task as an example:
This example shows a user customization file. There is no `image` specified.
61
84
62
-
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.
85
+
Or, you can reference the secret in-line with a built-in task, as shown in the following example:
The Dev Box VS Code extension and Dev Box CLI don't support hydrating secrets in the inner-loop testing workflow for customizations.
76
100
77
-
### Configure key vault access
101
+
### User customizations example
78
102
79
-
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 services bypass the firewall.
103
+
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.
80
104
81
-
:::image type="content" source="media/how-to-customizations-connect-resource-repository/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-customizations-connect-resource-repository/trusted-services-bypass-firewall.png":::
105
+
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.
82
106
83
-
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).
107
+
```yaml
108
+
$schema: "1.0"
109
+
tasks:
110
+
- name: git-clone
111
+
description: Clone this repository into C:\workspaces
The Dev Box Visual Studio Code extension and Dev Box CLI don't support hydrating secrets in the inner-loop testing workflow for customizations.
85
119
86
120
## Authenticate to Azure resources with service principals
87
121
88
-
Service principals let you securely authenticate to Azure resources exposing user credentials. You can create a Service Principal, assign the necessary role assignments, and use it to authenticate in a customization tasks, hydrating its credentials at customization time using the existing secrets feature. The next section explains the steps.
122
+
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.
89
123
90
124
1. Create a service principal in Azure Active Directory (Azure AD), and assign it the necessary roles for the resources you want to use.
91
125
92
126
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.
93
127
128
+
Example: CLI output when you create a service principal. Store the returned password in Key Vault and grant the Key Vault Secrets User role to the Dev Center project identity so the customization can hydrate the secret at runtime.
129
+
94
130
```azurecli
95
131
$ az ad sp create-for-rbac -n DevBoxCustomizationsTest
96
132
@@ -109,14 +145,16 @@ Service principals let you securely authenticate to Azure resources exposing use
109
145
Now you can authenticate in customization tasks, hydrating the service principal password from the Key Vault at customization time.
110
146
111
147
### Example: Download a file from Azure Storage
112
-
The following example shows you how to download a file from storage account. The YAML snippet defines a Dev Box customization that performs two main tasks:
148
+
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:
113
149
114
150
1. Installs the Azure CLI using the winget package manager.
115
151
116
152
1. Runs a PowerShell script that:
117
153
- Logs in to Azure using a service principal, with the password securely retrieved from Azure Key Vault.
118
154
- Downloads a blob (file) from an Azure Storage account using the authenticated session.
119
155
156
+
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.
157
+
120
158
```yaml
121
159
$schema: "1.0"
122
160
name: "devbox-customization"
@@ -142,7 +180,7 @@ The following example shows you how to download a file from storage account. The
142
180
This setup lets you automate secure use of Azure resources during Dev Box provisioning without exposing credentials in the script.
143
181
144
182
### Example: Download an artifact from Azure DevOps
145
-
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, and assign it to the **Readers** group. This step gives the necessary permissions to use build artifacts.
183
+
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.
146
184
147
185
After you configure these steps, use the service principal credentials in customization tasks to authenticate and download artifacts securely from Azure DevOps.
0 commit comments