Skip to content

Add lightweight typed configuration precedence sample - #19

Merged
balajibashyam merged 4 commits into
mainfrom
feature/configuration-secrets-sample
Aug 7, 2026
Merged

Add lightweight typed configuration precedence sample#19
balajibashyam merged 4 commits into
mainfrom
feature/configuration-secrets-sample

Conversation

@balajibashyam

Copy link
Copy Markdown
Contributor

Summary

Adds a minimal .NET 10 companion sample for the .NET 8 Configuration & Secrets Management: Typed Options, User Secrets & Feature Flags tutorial.

What's included

  • New sample: dotnet-8-essentials/configuration-secrets-environments/ — 12 files

    • Layered configuration precedence (appsettings.jsonappsettings.Development.json → User Secrets → CFGPLAY_ environment variables → command-line arguments)
    • Strongly typed AppOptions with DataAnnotations validation
    • Custom IValidateOptions<AppOptions> validator (HTTPS enforcement, placeholder API-key rejection)
    • ValidateOnStart for early startup failure on bad configuration
    • Lightweight FeatureFlagOptions with IOptionsSnapshot
    • Safe Development-only diagnostics endpoint with explicit allowlist and [REDACTED] API key
    • 8 integration tests covering provider precedence, validation, secret non-disclosure, and startup failure
    • Zero direct NuGet package references in the application project
  • Root README: New sample row in the table + updated repository structure tree

  • GitHub Actions: New test-config-precedence job in the shared workflow; path filters updated

Deliberately omitted (stays in the full tutorial)

Azure Key Vault, named options, IOptionsMonitor callbacks, live file reload, raw provider debug trees, external services, database configuration, SMTP configuration

Versions

  • .NET SDK: 10.0.302
  • Microsoft.AspNetCore.Mvc.Testing: 10.0.10
  • Microsoft.NET.Test.Sdk: 18.8.1
  • xunit.v3: 3.2.2
  • xunit.runner.visualstudio: 3.1.5
  • Application NuGet dependencies: none

Validation

  • dotnet restore — passed
  • dotnet build --configuration Release — passed (0 errors, 0 warnings)
  • dotnet test --configuration Release — passed (8/8)
  • Runtime precedence: timeout 40 (CLI wins over CFGPLAY_ 30, Dev 20, base 10)
  • Runtime diagnostics: [REDACTED] confirmed, no CI key leaked
  • Application package count: 0
  • Security scan — clean
  • YAML validation — passed

@balajibashyam
balajibashyam merged commit 290d6cb into main Aug 7, 2026
21 checks passed
@balajibashyam
balajibashyam deleted the feature/configuration-secrets-sample branch August 7, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant