Voyager.Configuration.MountPath
2.0.0
See the version list below for details.
dotnet add package Voyager.Configuration.MountPath --version 2.0.0
NuGet\Install-Package Voyager.Configuration.MountPath -Version 2.0.0
<PackageReference Include="Voyager.Configuration.MountPath" Version="2.0.0" />
<PackageVersion Include="Voyager.Configuration.MountPath" Version="2.0.0" />
<PackageReference Include="Voyager.Configuration.MountPath" />
paket add Voyager.Configuration.MountPath --version 2.0.0
#r "nuget: Voyager.Configuration.MountPath, 2.0.0"
#:package Voyager.Configuration.MountPath@2.0.0
#addin nuget:?package=Voyager.Configuration.MountPath&version=2.0.0
#tool nuget:?package=Voyager.Configuration.MountPath&version=2.0.0
Voyager.Configuration.MountPath
An ASP.NET Core extension for organizing JSON configuration files with support for environment-specific settings, encrypted values, and Docker/Kubernetes mount paths.
About
This library provides a simple way to organize JSON configuration files by file name (without extensions) and load them conditionally based on environment variables. Designed for containerized environments like Docker and Kubernetes, it allows you to:
- Organize configuration by concern: Separate files for database, logging, services, etc.
- Load files conditionally: Automatically loads environment-specific variants (e.g.,
database.json+database.Production.json) - Mount at runtime: Keep configuration outside container images using volume mounts
- Update without rebuilding: Change configuration without rebuilding or redeploying
โ ๏ธ DEPRECATION NOTICE: Built-in Encryption The built-in encryption feature is deprecated and will be removed in version 3.0. We recommend migrating to external secret management tools like Mozilla SOPS, Kubernetes Secrets, or cloud providers (Azure Key Vault, AWS Secrets Manager). See ADR-003: Encryption Delegation for migration guidance and rationale.
Features
- ๐ File-based organization: Pass file names (without extensions) as parameters
- ๐ฏ Conditional loading: Automatic environment-based file selection
- ๐ณ Container-friendly: Mount configuration from external volumes
- ๐ Hot reload: Automatically reload when configuration files change
- ๐ Dependency Injection: Full DI support with interfaces
- ๐๏ธ SOLID architecture: Interface-based design for testability
- ๐ฆ Multi-targeting: Supports .NET 4.8, .NET Core 3.1, .NET 6.0, and .NET 8.0
Installation
dotnet add package Voyager.Configuration.MountPath
Quick Start
Basic Usage: Single Configuration File
Pass file names (without .json extension) as parameters:
using Microsoft.Extensions.DependencyInjection;
var builder = Host.CreateDefaultBuilder(args);
builder.ConfigureAppConfiguration((context, config) =>
{
var provider = context.HostingEnvironment.GetSettingsProvider();
// Loads: appsettings.json + appsettings.{Environment}.json
config.AddMountConfiguration(provider, "appsettings");
});
File structure:
YourApp/
โโโ bin/
โ โโโ config/
โ โโโ appsettings.json # Base configuration
โ โโโ appsettings.Production.json # Environment-specific overrides
How it works:
- Loads base file:
appsettings.json(required) - Loads environment file:
appsettings.{ASPNETCORE_ENVIRONMENT}.json(optional by default) - Environment-specific values override base values
Customizing Settings
Configure custom mount paths or require environment-specific files:
builder.ConfigureAppConfiguration((context, config) =>
{
config.AddMountConfiguration(settings =>
{
settings.FileName = "myconfig"; // File name without extension
settings.ConfigMountPath = "configuration"; // Default: "config"
settings.HostingName = "Production"; // Override environment detection
settings.Optional = false; // Require environment file
});
});
Require environment-specific file:
builder.ConfigureAppConfiguration((context, config) =>
{
// Throws exception if appsettings.Production.json doesn't exist
config.AddMountConfiguration(context.HostingEnvironment.GetSettingsProviderForce());
});
Organizing Configuration by Concern
The key feature: organize configuration into separate files by concern, each loaded conditionally based on environment:
builder.ConfigureAppConfiguration((context, config) =>
{
var provider = context.HostingEnvironment.GetSettingsProvider();
// Each file name is loaded as: {name}.json + {name}.{Environment}.json
config.AddMountConfiguration(provider, "appsettings"); // App settings
config.AddMountConfiguration(provider, "database"); // Database config
config.AddMountConfiguration(provider, "logging"); // Logging config
config.AddMountConfiguration(provider, "services"); // External services
});
File structure:
config/
โโโ appsettings.json
โโโ appsettings.Production.json
โโโ database.json
โโโ database.Production.json
โโโ logging.json
โโโ logging.Production.json
โโโ services.json
โโโ services.Production.json
Benefits:
- Separation of concerns: Each file handles one aspect of configuration
- Conditional loading: Different values for Development, Production, Staging, etc.
- Easier management: Update only relevant files without touching others
Docker and Kubernetes Examples
Docker Example
Mount configuration files at runtime to separate concerns:
Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY bin/Release/net8.0/publish .
# Configuration will be mounted at runtime
ENTRYPOINT ["dotnet", "YourApp.dll"]
docker-compose.yml:
services:
myapp:
image: myapp:latest
volumes:
- ./config:/app/config:ro # Mount config folder
environment:
- ASPNETCORE_ENVIRONMENT=Production
config/ directory:
config/
โโโ database.json # Base database config
โโโ database.Production.json # Production overrides
โโโ logging.json # Base logging config
โโโ logging.Production.json # Production logging settings
Kubernetes Example
Use ConfigMaps for different configuration concerns:
database-config.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: database-config
data:
database.json: |
{
"ConnectionStrings": {
"Default": "Server=db;Database=myapp;..."
}
}
logging-config.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: logging-config
data:
logging.json: |
{
"Logging": {
"LogLevel": {
"Default": "Information"
}
}
}
deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
template:
spec:
containers:
- name: myapp
image: myapp:latest
volumeMounts:
- name: database-config
mountPath: /app/config/database.json
subPath: database.json
- name: logging-config
mountPath: /app/config/logging.json
subPath: logging.json
volumes:
- name: database-config
configMap:
name: database-config
- name: logging-config
configMap:
name: logging-config
Dependency Injection
Register configuration services:
// Register settings provider
builder.Services.AddVoyagerConfiguration();
// Register custom settings provider
builder.Services.AddVoyagerConfiguration<MyCustomSettingsProvider>();
// Use in your services
public class MyService
{
private readonly ISettingsProvider _settingsProvider;
public MyService(ISettingsProvider settingsProvider)
{
_settingsProvider = settingsProvider;
}
}
Advanced Usage
Custom Settings Provider
Implement ISettingsProvider for custom behavior:
public class MySettingsProvider : ISettingsProvider
{
public Settings GetSettings(string filename = "appsettings")
{
return new Settings
{
FileName = filename,
ConfigMountPath = "/custom/path",
HostingName = "Production"
};
}
}
// Register in DI
builder.Services.AddVoyagerConfiguration<MySettingsProvider>();
โ ๏ธ DEPRECATED: Encrypted Configuration Files
This feature is deprecated and will be removed in version 3.0. Please migrate to external secret management tools.
Built-in encryption (deprecated):
builder.ConfigureAppConfiguration((context, config) =>
{
var provider = context.HostingEnvironment.GetSettingsProvider();
var encryptionKey = Environment.GetEnvironmentVariable("ENCRYPTION_KEY");
// Regular files (plain text)
config.AddMountConfiguration(provider, "logging");
config.AddMountConfiguration(provider, "appsettings");
// โ ๏ธ DEPRECATED - Use SOPS instead
config.AddEncryptedMountConfiguration(encryptionKey, provider, "secrets");
config.AddEncryptedMountConfiguration(encryptionKey, provider, "connectionstrings");
});
Recommended alternative: Mozilla SOPS
Encrypt configuration files using SOPS before loading:
# Encrypt files with SOPS (one-time setup)
sops -e config/secrets.json > config/secrets.json
# Decrypt in your deployment script or init container
sops -d /config-encrypted/secrets.json > /config/secrets.json
// Load decrypted files normally - no code changes needed!
builder.ConfigureAppConfiguration((context, config) =>
{
var provider = context.HostingEnvironment.GetSettingsProvider();
config.AddMountConfiguration(provider, "logging");
config.AddMountConfiguration(provider, "secrets"); // Already decrypted by SOPS
config.AddMountConfiguration(provider, "appsettings");
});
Why migrate to SOPS?
- โ More secure: AES-256-GCM instead of legacy DES
- โ GitOps-friendly: Encrypted files can be committed to Git
- โ Key management: Integrates with AWS KMS, Azure Key Vault, GCP KMS, Age
- โ No code changes: Decrypt before loading, library code stays the same
- โ Better tooling: Edit encrypted files without manual decrypt/encrypt cycle
See ADR-003: Encryption Delegation to External Tools for:
- Detailed SOPS setup guide
- Migration examples for Kubernetes and Supervisor
- Comparison of secret management solutions
- Step-by-step migration path
Security Considerations
โ ๏ธ Encryption Feature Deprecated
Built-in encryption is deprecated and will be removed in version 3.0.
- Current implementation: Legacy DES encryption (56-bit, insecure)
- Status: Deprecated for backward compatibility only
- Recommendation: Migrate to external secret management tools
Recommended Secret Management Solutions
Instead of built-in encryption, use industry-standard tools:
Mozilla SOPS - File encryption for GitOps workflows
- Encrypts JSON/YAML values while keeping structure readable
- Supports AWS KMS, Azure Key Vault, GCP KMS, Age
- Git-friendly diffs
- Best for: GitOps, encrypted configs in Git
Kubernetes Secrets + Sealed Secrets
- Native Kubernetes secret management
- Sealed Secrets for GitOps-safe encrypted secrets
- Best for: Kubernetes deployments
Cloud Secret Managers
- Azure Key Vault, AWS Secrets Manager, GCP Secret Manager
- Enterprise-grade key rotation and audit logging
- Best for: Cloud-native applications
dotnet user-secrets
- For development environments only
- Best for: Local development
See ADR-003 for detailed migration guide.
Best Practices
- External Secret Management: Use SOPS, Kubernetes Secrets, or cloud providers
- File Permissions: Ensure configuration files have appropriate read permissions
- Container Security: Mount configuration volumes as read-only (
:ro) - Key Management: Never hardcode secrets in source code or images
- Separation of Concerns: Configuration loading โ secret management
Architecture
This library follows SOLID principles and modern .NET design patterns:
- Single Responsibility Principle: Each class has one well-defined responsibility
- Interface-based design:
IEncryptor,ISettingsProvider,ICipherProvider,IEncryptorFactory - Dependency Injection: Full support for DI container registration
- Extension methods: Organized by responsibility for better maintainability
Extension Methods Organization
The library provides extension methods organized by their specific concerns:
ConfigurationExtension: Non-encrypted mount configurationEncryptedMountConfigurationExtensions: Encrypted mount configuration (high-level API)EncryptedJsonFileExtensions: Encrypted JSON file operations (low-level API)ServiceCollectionExtensions: Dependency injection registration
All extension methods are placed in the Microsoft.Extensions.DependencyInjection namespace following .NET conventions.
Note: The
ConfigurationEncryptedExtensionclass is deprecated and will be removed in version 3.0. UseEncryptedMountConfigurationExtensionsandEncryptedJsonFileExtensionsinstead.
Documentation
- Architecture Decision Records - Architectural decisions and their rationale
- ADR-001: Extension Methods Organization - How extension methods are organized
- ADR-002: Settings Builder Pattern - Why Action<Settings> over Builder Pattern
- ADR-003: Encryption Delegation to External Tools - Migration guide from built-in encryption to SOPS
- ROADMAP - Planned improvements and feature roadmap
- Documentation Index - Complete documentation overview
Migration Guide
For migration from version 1.x to 2.x, see Migration Guide.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Authors
- @andrzejswistowski - Original author and maintainer
See also the list of contributors who participated in this project.
Acknowledgements
- Przemysลaw Wrรณbel - Icon design
- All contributors who have helped improve this library
Support
If you encounter any issues or have suggestions:
- Open an issue on GitHub Issues
- Check the documentation
- Review the ROADMAP for planned features
- Read Architecture Decision Records for design rationale
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.1 is compatible. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETCoreApp 3.1
- Microsoft.Extensions.Configuration.Json (>= 6.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.1)
-
.NETFramework 4.8
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
-
net6.0
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
-
net8.0
- Microsoft.Extensions.Configuration.Json (>= 8.0.1)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.1-preview.1 | 34 | 2/10/2026 |
| 2.0.0 | 84 | 2/10/2026 |
| 2.0.0-preview.1.3 | 30 | 2/10/2026 |
| 2.0.0-preview.1.2 | 28 | 2/10/2026 |
| 1.3.0-preview.5.15 | 40 | 2/9/2026 |
| 1.3.0-preview.5 | 40 | 2/7/2026 |
| 1.3.0-preview.4 | 49 | 2/7/2026 |
| 1.3.0-preview.3 | 40 | 2/6/2026 |
| 1.3.0-preview.2 | 43 | 2/6/2026 |
| 1.3.0-preview.1 | 49 | 2/5/2026 |
| 1.2.8 | 1,571 | 9/26/2024 |
| 1.2.7 | 838 | 6/7/2024 |
| 1.2.6 | 186 | 6/6/2024 |
| 1.2.5 | 223 | 6/6/2024 |
| 1.2.4 | 191 | 6/6/2024 |
| 1.1.3 | 214 | 6/6/2024 |
| 1.1.2 | 557 | 12/1/2023 |
| 1.1.1 | 223 | 11/21/2023 |
| 1.1.0 | 217 | 11/17/2023 |
| 1.0.1 | 345 | 4/12/2023 |
v1.3.0: SRP refactoring - Extension methods split by responsibility (EncryptedMountConfigurationExtensions, EncryptedJsonFileExtensions). ConfigurationEncryptedExtension marked as obsolete. See ADR-001 for details.