appsettings.json Diff for Environment Drift
TL;DR: Two appsettings.json files can both be valid JSON but disagree on keys, types, or critical values like connection strings and endpoints.
When Valid JSON Still Breaks Prod
Configuration binding in .NET is sensitive to both key paths and types. Common drift patterns include:
- Missing sections like
ConnectionStringsorRedisin one environment - Different logging levels between staging and prod
- Endpoints pointing at old services or regions
Example: Connection String Drift
// staging
{
"ConnectionStrings": {
"Default": "Server=sql-staging;Database=app;User Id=app;Password=staging;"
}
}
// production
{
"ConnectionStrings": {
"Default": "Server=sql-prod;Database=app;User Id=app;Password=prod;"
}
}
Both configs are valid JSON, but a hidden drift in ConnectionStrings.Default can explain why staging works while prod fails or connects to the wrong database.
Run a Safe appsettings.json Diff
Use the Config Diff Inspector to flatten both configs and compare:
- Missing keys like
Redis.HostorAuth.Authority - Type mismatches on flags and numeric limits
- Changed critical values for databases, queues, and APIs
Compare appsettings.json Files
Paste two appsettings.json files into the Config Diff Inspector to see exactly where prod and staging drift.