Configuration Sources
The AppHost builder supports all standard .NET configuration sources:Accessing Configuration
Access configuration in your AppHost:Adding Configuration Sources
Add additional configuration sources:Parameters
Parameters are a special type of configuration designed for deployment-time values. They can be:- Prompted for during
azddeployment - Stored securely in user secrets or Azure Key Vault
- Validated and typed
Creating Parameters
- String Parameter
- Parameter with Default
- Generated Parameter
secret: true flag marks the parameter as sensitive, hiding it in logs and the dashboard.Using Parameters
Use parameters in resource configuration:Parameter Resolution
Parameters are resolved from multiple sources in this order:User Secrets
User secrets provide a secure way to store sensitive configuration during development.Enabling User Secrets
Add aUserSecretsId to your AppHost project:
MyApp.AppHost.csproj
Setting Secrets
Set secrets from the command line:Automatic API Keys
Aspire automatically generates and stores some API keys in user secrets:- Dashboard browser token
- OTLP API key for telemetry
- Resource service API key
Configuring Resources
Pass configuration to resources in several ways:Environment Variables
The most common way to configure resources:Configuration Callbacks
Use callbacks for dynamic configuration:Command-line Arguments
Pass arguments to projects and executables:Environment-Specific Configuration
Configure resources differently based on the environment:Setting the Environment
Control the environment via:- Environment Variable
- Command-line
- launchSettings.json
Connection String Configuration
Override resource connection strings via configuration:appsettings.json
Configuration in Publish Mode
When generating deployment manifests, configuration is handled differently:Common Configuration Patterns
Feature Flags
Feature Flags
Use configuration to control features:
External Service URLs
External Service URLs
Configure external services via parameters:
Database Credentials
Database Credentials
Use parameters for credentials:
Replica Count
Replica Count
Configure scaling via configuration:
Configuration Best Practices
Use Parameters for Secrets
Always use parameters with
secret: true for sensitive values like API keys and passwords.Environment-Specific Config
Use environment-specific configuration files (appsettings.Development.json, appsettings.Production.json).
User Secrets in Development
Store development secrets in user secrets, never commit them to source control.
Validate Configuration
Validate required configuration at startup to fail fast if misconfigured.
Next Steps
Environment Variables
Learn how to set environment variables
Deployment
Deploy your configured application