Understanding Resources
Aspire makes it easy to define everything your app needs—frontends, APIs, databases, and more—using the AppHost. Just describe your resources in code, and Aspire handles the connections for you.
Types of Resources
Section titled “Types of Resources”Resources can include:
- AI Services: Large Language Models, AI endpoints, and cognitive services.
- Caches: Redis, in-memory caches, and distributed caching solutions.
- Containers: Docker containers for databases, message brokers, and other services.
- Databases: SQL Server, PostgreSQL, MySQL, MongoDB, and other data stores.
- Executables: Console applications, scripts, and background services.
- Frameworks: Web applications, APIs, and microservices built with various frameworks.
- Messaging Services: Service Bus, RabbitMQ, Kafka, and other messaging systems.
- Projects: .NET projects, Node.js applications, Python services, and more.
- Storage: Blob storage, file systems, and cloud storage services.
Resource Dependencies
Section titled “Resource Dependencies”Resources work together through explicit dependencies that you define in your AppHost. When you model these dependencies, Aspire automatically handles the wiring, startup order, and connection management—letting you focus on building your app instead of managing infrastructure.
For example, if your API service depends on a database and configures a wait strategy, Aspire can automatically inject the connection string and ensure the database is started before the API service.
- Start the database first.
- Wait for it to become healthy.
- Inject the connection string into your API service.
- Start your API service.
Discover how to model Resource Hierarchies and represent complex app structures.
Resource Configuration
Section titled “Resource Configuration”Resources can be configured in various ways:
- Environment Variables: Set configuration through environment variables.
- Connection Strings: Automatically generated and injected for dependent services.
- Resource Parameters: Configure ports, volumes, and other resource-specific settings.
- Health Checks: Define custom health check endpoints for your services.
Custom Resources
Section titled “Custom Resources”Under-the-hood, every integration is either a Container or Executable, meaning you can add any container image, codebase, script, or cloud resource to your AppHost. Creating reusable Aspire integrations is just like creating a reusable UI component. It can be as simple or complex as you need, and is fully shareable. Learn more about creating custom resources for Aspire.
Resource Lifecycle
Section titled “Resource Lifecycle”Aspire manages the complete lifecycle of your resources during local development:
- Discovery: Resources are discovered and their dependencies are analyzed.
- Startup: Resources are started in dependency order, respecting their relationships.
- Health Monitoring: Resource health and readiness are continuously monitored.
- Shutdown: Resources are gracefully stopped when the application terminates.
Explore how Built-In Resources and Lifecycle work together to power your applications.