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
+88-5Lines changed: 88 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ ms.custom:
12
12
- ai-seo-date:05/10/2025
13
13
- ai-gen-description
14
14
ms.topic: how-to
15
-
ms.date: 05/10/2025
15
+
ms.date: 07/22/2025
16
16
---
17
17
18
18
# Connect to Azure resources or clone private repositories by using customizations
@@ -74,7 +74,7 @@ tasks:
74
74
75
75
The Dev Box VS Code extension and Dev Box CLI don't support hydrating secrets in the inner-loop testing workflow for customizations.
76
76
77
-
## Configure key vault access
77
+
### Configure key vault access
78
78
79
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.
80
80
@@ -83,8 +83,91 @@ The dev center needs access to your key vault. Because dev centers don't support
83
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).
84
84
85
85
86
+
## Authenticate to Azure resources with service principals
87
+
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.
89
+
90
+
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
+
92
+
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
+
94
+
```azurecli
95
+
$ az ad sp create-for-rbac -n DevBoxCustomizationsTest
96
+
97
+
{
98
+
"appId": "...",
99
+
"displayName": "DevBoxCustomizationsTest",
100
+
"password": "...",
101
+
"tenant": "..."
102
+
}
103
+
```
104
+
105
+
1. Store the password returned above in a Key Vault secret, like this: `https://mykeyvault.vault.azure.net/secrets/password`
106
+
107
+
1. On the Key Vault, grant the *Key Vault Secrets User* role to the project identity.
108
+
109
+
Now you can authenticate in customization tasks, hydrating the service principal password from the Key Vault at customization time.
110
+
111
+
### 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:
113
+
114
+
1. Installs the Azure CLI using the winget package manager.
115
+
116
+
1. Runs a PowerShell script that:
117
+
- Logs in to Azure using a service principal, with the password securely retrieved from Azure Key Vault.
118
+
- Downloads a blob (file) from an Azure Storage account using the authenticated session.
This setup lets you automate secure use of Azure resources during Dev Box provisioning without exposing credentials in the script.
143
+
144
+
### 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.
146
+
147
+
After you configure these steps, use the service principal credentials in customization tasks to authenticate and download artifacts securely from Azure DevOps.
148
+
149
+
#### Add a service principal to an Azure DevOps organization
150
+
151
+
To add a service principal to your Azure DevOps organization:
152
+
153
+
1. Sign in to your Azure DevOps organization, and open **Organization settings**.
154
+
1. In the menu, select **Users**.
155
+
1. On the **Users** page, select **Add users**.
156
+
1. In the **Add new users** dialog, enter the following information:
157
+
158
+
:::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":::
159
+
160
+
-**Users**: Enter the service principal's Application ID (appId) as the user email.
161
+
-**Access Level**: Select **Basic**.
162
+
-**Add to project**: Select the project where you want to add the service principal.
163
+
-**Azure DevOps groups**: Assign the service principal to the **Readers** group.
164
+
165
+
1. Complete the process to grant the necessary permissions.
166
+
167
+
For details on how to add users to DevOps organizations, see [Add organization users and manage access](/azure/devops/organizations/accounts/add-organization-users).
168
+
86
169
## Related content
87
170
88
-
- [Microsoft Dev Box customizations](concept-what-are-dev-box-customizations.md)
89
-
- [Configure Dev Box imaging](how-to-configure-dev-box-imaging.md)
90
-
- Learn how to [add and configure a catalog from GitHub or Azure Repos](../deployment-environments/how-to-configure-catalog.md).
171
+
-Learn how to [Set and retrieve a secret from Azure Key Vault using the Azure portal](/azure/key-vault/secrets/quick-create-portal).
172
+
-Learn how to [Add and configure a catalog from GitHub or Azure Repos](../deployment-environments/how-to-configure-catalog.md).
173
+
- Learn how to [Use service principals & managed identities in Azure DevOps](/azure/devops/integrate/get-started/authentication/service-principal-managed-identity).
0 commit comments