Azure Key Vault Essentials
Azure Key Vault provides a secure, centralized store for secrets, keys, and certificates.-
Purpose
Securely store API keys, passwords, certificates, and cryptographic keys. -
Access Policies
Configure who can read, write, or manage vault objects. -
Monitoring & Logging
Integrate with Azure Monitor and Azure Activity Logs to audit access and changes. -
Best Practices
- Enable soft-delete and purge protection
- Enforce role-based access control (RBAC)
- Regularly rotate and audit secrets
Enable purge protection to prevent accidental or malicious deletion of vault contents.
Integrating Secret Management in DevSecOps Pipelines
Implement automated, secure retrieval of secrets in CI/CD workflows.1. GitHub Actions
- Use the Azure/login action to authenticate.
- Fetch secrets from Key Vault at runtime.
- Apply environment protection rules.
- Rotate credentials on a regular schedule.
2. Azure Pipelines
- Link Key Vault as a Variable Group.
- Reference secrets in YAML or classic pipelines without exposing them in code.
- Turn on diagnostic logging for Key Vault access.
3. General Best Practices
- Enforce least-privilege for all identities and service principals.
- Rotate secrets, keys, and certificates at least every 90 days.
- Monitor access logs and trigger alerts on anomalous patterns.
Always restrict service principal permissions to only the required Azure scopes. Overprivileged identities increase security risk.
Azure Pipelines Service Connections
Service connections allow pipelines to authenticate with external systems without embedding credentials in code.Overview
Securely connect to Azure, GitHub, container registries, and third-party services.Types of Service Connections
| Service Connection Type | Use Case | Example CLI Command |
|---|---|---|
| Azure Resource Manager | Deploy and manage Azure resources | az devops service-endpoint azurerm create ... |
| GitHub | Access GitHub repositories | az devops service-endpoint github create ... |
| Docker Registry / ACR | Push/pull container images | — |
| Third-Party (SonarQube, Jenkins) | Integrate analysis and CI tools | — |
Configuration Steps
- In Azure DevOps, go to Project Settings > Service connections.
- Click New service connection and select the type.
- Provide authentication details (service principal, token, or PAT).
- Assign the minimal required scope and permissions.
- Validate and save the connection.
ARM Service Connection
- Use an existing or new service principal with a Contributor or custom role.
- Specify subscription ID, resource group, and scope.
- Test the connection before saving.
GitHub Service Connection
- Authorize Azure DevOps via OAuth or provide a Personal Access Token (PAT).
- Limit repository permissions to only those needed for your pipelines.

Usage in Pipelines
Reference service connections in YAML tasks or classic releases:Best Practices
- Audit service connection permissions regularly.
- Adopt custom roles with just-enough permissions.
- Rotate service principal credentials and tokens on a scheduled basis.