Mount secrets from Key Vault

DevOps, Hands On30 minutesCosts moneySteps checked 14 November 2026By Cloud Hands On

In this task you'll give a pod a secret from Key Vault without putting it in YAML.

The Secrets Store CSI driver with the Azure Key Vault provider mounts secrets as files when a pod starts. The secret lives in Key Vault; the YAML only names it in a SecretProviderClass.

On AKS it's an add-on with its own managed identity: give that identity Key Vault Secrets User on the one vault it needs.

Example. SS Kaiser's database password moved out of the deployment YAML into Key Vault; the pod reads /mnt/secrets/db-password, and rotating the password needs no code change.

Costs money. This task creates resources that are charged while they exist. Delete them as soon as you finish.

Before you start

You need: An AKS cluster and a Key Vault. Time: 30 minutes.

Where to look

  1. az aks enable-addons
  2. SecretProviderClass
  3. pod volume

Steps

  1. Run az aks enable-addons --addons azure-keyvault-secrets-provider -g <group> -n <cluster>.
  2. Give the add-on's identity (addonProfiles.azureKeyvaultSecretsProvider.identity) Key Vault Secrets User on the vault.
  3. Apply a SecretProviderClass with keyvaultName, tenantId, useVMManagedIdentity true and the identity's client ID.
  4. Add a csi volume (driver secrets-store.csi.k8s.io) to the pod and mount it read-only.

Commands

# Connect kubectl to the cluster first
az aks get-credentials -g <group> -n <cluster>
az aks enable-addons --addons azure-keyvault-secrets-provider -g <group> -n <cluster>
az aks show -g <group> -n <cluster> --query addonProfiles.azureKeyvaultSecretsProvider.identity
kubectl get secretproviderclass -A

Watch out for

Cost
The add-on is free; Key Vault charges per 10,000 operations (pennies).
Security
Scope the role to one vault. Treat any password that was ever in YAML as leaked and rotate it.
Common mistakes
Using the identity's object ID where the client ID is needed, and forgetting the vault uses RBAC, not access policies.

Clean up

Delete the SecretProviderClass, disable the add-on, and remove the role assignment.

Words to know

CSI driver
A plug-in that mounts storage (here, secrets) into pods.
SecretProviderClass
Says which vault and which secrets to mount.

Tick off each step and track your progress in the guide.

Open this task in DevOps, Hands On

Keep going