Azure

Azure DevOps Crash Course (Part 6): Secrets and Settings with Variable Groups and Key Vault

DEV Community: #dotnet Rehana Parveen
Azure

A hands-on walkthrough of moving an ASP.NET Core API's per-environment settings into Azure DevOps variable groups and its real secrets into Key Vault, then feeding both to Dev and Prod App Service deployments from one build artifact.

Key points

  • appsettings.json keeps only safe defaults; environment-specific values move into variable groups.
  • A Key Vault-linked variable group shows the pipeline only the secret name, resolving the value at run time.
  • The service connection identity needs the Key Vault Secrets User role or Get/List access policy permissions.
  • Secret variables are masked in logs but reach scripts only when passed as task inputs.
  • Nested configuration keys use double underscores, so `ConnectionStrings:Default` becomes `ConnectionStrings__Default`.
  • For local development, secrets belong in `dotnet user-secrets` rather than appsettings files.

Why it matters

The people who gain most here are teams whose configuration still lives in YAML or in appsettings files that get committed, often small teams where the same person writes the pipeline and the code. The mechanical part is easy to copy; the discipline is not: pipeline permissions on variable groups and the vault's RBAC-versus-access-policy choice are the two places where a setup like this silently fails.

Before adopting it, check whether a secret is already in Git history. Linking Key Vault afterwards does not erase it, so rotation comes first. For workloads already on App Service this is a natural stepping stone, and the usual next move is replacing connection strings with managed identity.

Real-world use

  • Deploying the same build artifact to separate Dev and Prod App Service instances with different settings
  • Managing a feature flag or service URL that differs per environment through the pipeline
  • A production API key or connection string that must be rotated without editing pipeline code
  • Developing the same API locally with `dotnet user-secrets` so secrets stay out of the repo

This summary was generated by the agent from the original post on DEV Community: #dotnet. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message