2 minutes

33. Use Azure Key Vault and managed identity

Date: 2026-10-12

Status

Proposed

Context

The three Unicorn services need about fifteen credentials: identity provider, Google OAuth, AI model, Cosmos DB, Service Bus, GitHub and the notification provider. The CI workflow passes most of them as Docker build arguments, and the Dockerfiles copy them into environment variables, so they are stored in the image layers pushed to the container registry. The notification credentials are hard-coded in the processing service and are in git history. The Cosmos DB and Service Bus keys are passed at deploy time into the Dapr components. Requirement NFR-SEC-004 says no credential may live in source code or tracked configuration.

The full analysis, with three options and the evidence from Microsoft Learn, is in the ArcKit record ARC-001-ADR-001 (projects/001-unicorn/decisions/ in the workspace).

Decision

We will store every runtime credential in one Azure Key Vault and give it to the services at run time, never at build time.

Each container app gets a user-assigned managed identity with the Key Vault Secrets User role. Container Apps secrets become Key Vault references with versionless URIs and reach the code as environment variables, so the code does not change.

The Dapr components for Cosmos DB and Service Bus use managed identity instead of keys, and those keys are then disabled.

The CI workflow stops passing build arguments, and the Dockerfiles keep no credentials. Every credential that was in an image or in git is rotated.

Local development keeps untracked .env files.

--- config: look: handDrawn theme: neutral --- graph LR KV[Key Vault] -->|Key Vault references| ACA[Container Apps] MI[Managed identity] --> KV MI --> DB[Cosmos DB] MI --> SB[Service Bus] ACA --> MI

Consequences

No credential is stored in an image, a repository or a deployment parameter. Rotation needs no rebuild: a new version is picked up within 30 minutes. We add a Key Vault, identities and role assignments to the Bicep files. Key Vault operations are billed per 10,000 transactions; the price is to be confirmed on the first invoice, under the 15 euro billing alert. Before anything else, every exposed credential must be rotated and old image versions deleted from the registry. The Key Vault and the managed identity must be added to the IcePanel model, with their connections tagged.