Skip to content

Commit e8cb9ef

Browse files
author
RoseHJM
committed
Adjust image size
1 parent ca54f51 commit e8cb9ef

File tree

3 files changed

+44
-34
lines changed

3 files changed

+44
-34
lines changed

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

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The dev center needs access to your key vault. Because dev centers don't support
8282

8383
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).
8484

85+
8586
## Authenticate to Azure resources with service principals
8687

8788
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
9091

9192
1. Create a service principal in Azure Active Directory (Azure AD) and assign it the necessary roles for the resources you want to access.
9293

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

95-
```azurecli
96+
```azurecli
9697
$ az ad sp create-for-rbac -n DevBoxCustomizationsTest
9798
9899
{
@@ -101,45 +102,45 @@ Create a Service Principal with required role assignments, and use it to log in
101102
"password": "...",
102103
"tenant": "..."
103104
}
104-
```
105+
```
105106

107+
1. Store the password returned above in a Key Vault secret, like this: `https://mykeyvault.vault.azure.net/secrets/password`
106108

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

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

113113
### Example: Download a file from Azure Storage
114114

115115
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:
116116

117117
1. Installs the Azure CLI using the winget package manager.
118+
118119
1. Runs a PowerShell script that:
119120
- Logs in to Azure using a service principal, with the password securely retrieved from Azure Key Vault.
120121
- Downloads a blob (file) from an Azure Storage account using the authenticated session.
121122

122-
```yaml
123-
$schema: "1.0"
124-
name: "devbox-customization"
125-
tasks:
126-
- name: ~/winget
127-
parameters:
128-
package: Microsoft.AzureCLI
129-
- name: ~/powershell
130-
parameters:
131-
command: |
132-
az login --service-principal `
133-
--username <appId> `
134-
--password {{https://mykeyvault.vault.azure.net/secrets/password}} `
135-
--tenant <tenantId>
136-
az storage blob download `
137-
--account-name <storage_account_name> `
138-
--container-name <container_name> `
139-
--name <blob_name> `
140-
--file <local_file_path> `
141-
--auth-mode login
142-
```
123+
```yaml
124+
$schema: "1.0"
125+
name: "devbox-customization"
126+
tasks:
127+
- name: ~/winget
128+
parameters:
129+
package: Microsoft.AzureCLI
130+
- name: ~/powershell
131+
parameters:
132+
command: |
133+
az login --service-principal `
134+
--username <appId> `
135+
--password {{https://mykeyvault.vault.azure.net/secrets/password}} `
136+
--tenant <tenantId>
137+
az storage blob download `
138+
--account-name <storage_account_name> `
139+
--container-name <container_name> `
140+
--name <blob_name> `
141+
--file <local_file_path> `
142+
--auth-mode login
143+
```
143144

144145
This setup allows automated, secure access to Azure resources during Dev Box provisioning, without exposing credentials in the script.
145146

@@ -148,25 +149,34 @@ You can also download build artifacts from Azure DevOps (ADO) by using a service
148149

149150
Once configured, you can use the service principal credentials in your customization tasks to authenticate and download artifacts securely from Azure DevOps.
150151

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:
152155

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**.
155159
1. Enter the service principal's Application ID (appId) as the user email.
156160

157161
:::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:
158168

159-
1. Add to the readers group
160169
1. Assign the user to the **Readers** group.
161170

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.":::
163172

164173
1. Complete the process to grant the necessary permissions.
165174

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).
167176

168177
## Related content
169178

170179
- [Microsoft Dev Box customizations](concept-what-are-dev-box-customizations.md)
171180
- [Configure Dev Box imaging](how-to-configure-dev-box-imaging.md)
172181
- 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).
Loading
Loading

0 commit comments

Comments
 (0)