- Home
- Skills
- Aaronontheweb
- Dotnet Skills
- Aspire Configuration
aspire-configuration_skill
- Shell
643
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill aaronontheweb/dotnet-skills --skill aspire-configuration- SKILL.md5.0 KB
Overview
This skill configures an Aspire AppHost to emit explicit application configuration via environment variables so application code remains free of Aspire clients and service discovery. It prescribes a pattern where AppHost owns Aspire hosting packages and translates resource outputs into concrete config keys. The application binds to IConfiguration/IOptions<T> and initializes SDKs from plain configuration values, preserving production parity and portability.
How this skill works
AppHost provisions Aspire resources (databases, containers, services) and maps their outputs to explicit environment variables or configuration keys using WithEnvironment and WithReference helpers. The application reads these keys through IConfiguration and IOptions<T> and instantiates SDKs (e.g., S3 client, Postgres connection) directly from those values. No Aspire client or service discovery packages are referenced by the app — orchestration concerns stay in AppHost and every injected value can be reproduced as a production env var or config file.
When to use it
- Wiring AppHost resources to application configuration in Aspire-based repositories
- Ensuring production configuration is transparent and portable without Aspire runtime
- Keeping application projects free of Aspire client/service-discovery packages
- Designing feature toggles or test overrides without changing application code paths
- Maintaining parity between local/dev/test and production configuration
Best practices
- Keep all Aspire hosting packages inside AppHost only; application projects must not reference them
- Map each Aspire resource output to explicit config keys (e.g., ConnectionStrings__Postgres, BlobStorage__ServiceUrl)
- Use IOptions<T> with data annotation validation and ValidateOnStart for infrastructure settings
- Ensure every AppHost-injected value can be represented as an environment variable or config file in production
- Drive feature toggles and test overrides through AppHost configuration, not by altering app code
Example use cases
- Expose a Postgres connection string from AppHost as ConnectionStrings__Postgres and bind it to DbContext via IConfiguration
- Provision a Minio container in AppHost and set BlobStorage__ServiceUrl/AccessKey/SecretKey for the API to consume
- Disable persistence in test runs by toggling volumes from AppHost and passing BlobStorage__Enabled=false to the app
- Run integration tests with DistributedApplicationTestingBuilder by overriding config keys instead of injecting Aspire clients
- Migrate an app to Kubernetes by ensuring all AppHost-emitted env vars map directly to deployment environment variables
FAQ
Aspire hosting is an orchestration concern. Removing Aspire references keeps application code portable and ensures configuration can be replicated in production without Aspire-specific mechanisms.
How do I validate injected configuration at startup?
Bind infrastructure sections to IOptions<T>, decorate options with data annotations, and call ValidateOnStart so the app fails fast on invalid config.