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
+44-34Lines changed: 44 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -82,6 +82,7 @@ The dev center needs access to your key vault. Because dev centers don't support
82
82
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
86
87
87
88
You can use service principals to authenticate to Azure resources in your customizations. Service principals are a secure way to access Azure resources without using user credentials.
@@ -90,9 +91,9 @@ Create a Service Principal with required role assignments, and use it to log in
90
91
91
92
1. Create a service principal in Azure Active Directory (Azure AD) and assign it the necessary roles for the resources you want to access.
92
93
93
-
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.
94
+
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.
94
95
95
-
```azurecli
96
+
```azurecli
96
97
$ az ad sp create-for-rbac -n DevBoxCustomizationsTest
97
98
98
99
{
@@ -101,45 +102,45 @@ Create a Service Principal with required role assignments, and use it to log in
101
102
"password": "...",
102
103
"tenant": "..."
103
104
}
104
-
```
105
+
```
105
106
107
+
1. Store the password returned above in a Key Vault secret, like this: `https://mykeyvault.vault.azure.net/secrets/password`
106
108
107
-
2. Store the password returned above in a Key Vault secret, like this: `https://mykeyvault.vault.azure.net/secrets/password`
109
+
1. On the Key Vault, grant the *Key Vault Secrets User* role to the project identity.
108
110
109
-
3. On the Key Vault, grant the *Key Vault Secrets User* role to the project identity.
110
-
111
-
Now you can authenticate in customization tasks, hydrating the service principal password from the Key Vault at customization time.
111
+
Now you can authenticate in customization tasks, hydrating the service principal password from the Key Vault at customization time.
112
112
113
113
### Example: Download a file from Azure Storage
114
114
115
115
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:
116
116
117
117
1. Installs the Azure CLI using the winget package manager.
118
+
118
119
1. Runs a PowerShell script that:
119
120
- Logs in to Azure using a service principal, with the password securely retrieved from Azure Key Vault.
120
121
- Downloads a blob (file) from an Azure Storage account using the authenticated session.
This setup allows automated, secure access to Azure resources during Dev Box provisioning, without exposing credentials in the script.
145
146
@@ -148,25 +149,34 @@ You can also download build artifacts from Azure DevOps (ADO) by using a service
148
149
149
150
Once configured, you can use the service principal credentials in your customization tasks to authenticate and download artifacts securely from Azure DevOps.
150
151
151
-
To add a service principal to your Azure DevOps organization: and the Readers group:
152
+
#### Add a service principal to Azure DevOps organization
153
+
154
+
To add a service principal to your Azure DevOps organization:
152
155
153
-
1. Go to your Azure DevOps organization settings.
154
-
1. Select **Users** and click **Add users**.
156
+
1. Sign in to your Azure DevOps organization and open **Organization settings**.
157
+
1. In the left menu, select **Users**.
158
+
1. On the **Users** page, select **Add users**.
155
159
1. Enter the service principal's Application ID (appId) as the user email.
156
160
157
161
:::image type="content" source="media/how-to-customizations-connect-resource-repository/dev-box-customizations-devops-add-service-principal.png" alt-text="Screenshot showing how to add a service principal to Azure DevOps.":::
162
+
163
+
For details on how to add users to DevOps organizations, see [Add organization users and manage access](/azure/devops/organizations/accounts/add-organization-users).
164
+
165
+
#### Add the service principal to the Readers group
166
+
167
+
To add the service principal to the **Readers** group:
158
168
159
-
1. Add to the readers group
160
169
1. Assign the user to the **Readers** group.
161
170
162
-
:::image type="content" source="media/how-to-customizations-connect-resource-repository/dev-box-customizations-devops-add-readers.png" alt-text="Screenshot showing how to add a service principal to the Readers group in Azure DevOps.":::
171
+
:::image type="content" source="media/how-to-customizations-connect-resource-repository/dev-box-customizations-devops-add-readers.png" alt-text="Screenshot showing how to add a user to the Readers group in Azure DevOps.":::
163
172
164
173
1. Complete the process to grant the necessary permissions.
165
174
166
-
For detailed steps, see [Add users and groups to Azure DevOps](/azure/devops/organizations/security/add-users-team-project).
175
+
For detailed steps, see [Add users and groups to Azure DevOps](/azure/devops/organizations/security/add-remove-manage-user-group-security-group).
167
176
168
177
## Related content
169
178
170
179
-[Microsoft Dev Box customizations](concept-what-are-dev-box-customizations.md)
171
180
-[Configure Dev Box imaging](how-to-configure-dev-box-imaging.md)
172
181
- Learn how to [add and configure a catalog from GitHub or Azure Repos](../deployment-environments/how-to-configure-catalog.md).
182
+
- Learn how to [Use service principals & managed identities in Azure DevOps](/azure/devops/integrate/get-started/authentication/service-principal-managed-identity).
0 commit comments