Community코딩 & 개발github.com

aspire-configuration

Aspire AppHost가 명시적인 환경 변수를 통해 앱 구성을 내보내도록 구성합니다. 앱 코드가 Aspire 클라이언트와 서비스 검색에 의존하지 않도록 유지합니다.

aspire-configuration란 무엇인가요?

이 스킬은 .NET Aspire 기반 프로젝트에서 애플리케이션 구성을 명시적으로 관리하는 방법을 제공합니다. AppHost가 Aspire 리소스의 출력을 환경 변수로 변환하여 애플리케이션에 전달함으로써, 애플리케이션 코드는 Aspire 클라이언트 패키지나 서비스 검색에 의존하지 않고 `IOptions<T>` 또는 `Configuration`만을 사용할 수 있습니다. 이를 통해 개발 환경과 프로덕션 환경 간의 구성 일관성을 유지하고, 프로덕션에서 Aspire 없이도 동일한 구성을 환경 변수나 설정 파일로 표현할 수 있습니다. 주로 C# 언어를 사용하는 .NET Aspire 프로젝트에서 활용되며, Claude Code, Cursor, Codex 등의 AI 어시스턴트가 AppHost와 애플리케이션 코드를 작성할 때 일관된 패턴을 따르도록 돕습니다.

지원 대상✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Aaronontheweb/dotnet-skills/tree/main/skills/aspire-configuration

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Aspire 구성

이 스킬을 사용해야 하는 경우

다음과 같은 경우 이 스킬을 사용하세요:

  • Aspire 기반 리포지토리에서 AppHost 리소스를 애플리케이션 구성에 연결할 때
  • 프로덕션 구성이 Aspire 외부에서도 투명하고 이식 가능하도록 보장해야 할 때
  • 애플리케이션 코드에서 Aspire 클라이언트/서비스 검색 패키지를 사용하지 않아야 할 때
  • 앱 코드 경로를 변경하지 않고 개발/테스트를 위한 기능 토글을 설계할 때

핵심 원칙

  1. AppHost가 Aspire 인프라 패키지를 소유함

    • Aspire 호스팅 패키지는 AppHost에만 속합니다.
    • 앱 프로젝트는 Aspire 클라이언트/서비스 검색 패키지를 참조해서는 안 됩니다.
  2. 명시적 구성만 사용

    • AppHost는 리소스 출력을 명시적인 구성 키(환경 변수)로 변환해야 합니다.
    • 앱 코드는 IOptions<T> 또는 Configuration에만 바인딩됩니다.
  3. 프로덕션 동등성과 투명성

    • AppHost가 주입하는 모든 값은 Aspire 없이도 프로덕션에서 환경 변수 또는 구성 파일로 표현 가능해야 합니다.
    • 불투명한 서비스 검색 및 암시적 구성을 피하세요.

구성 흐름

AppHost 리소스 -> WithEnvironment(...) -> 앱 구성 키 -> 앱의 IOptions<T>

AppHost는 Aspire 리소스를 명시적인 앱 설정으로 변환할 책임이 있습니다. 애플리케이션은 Aspire 클라이언트나 서비스 검색을 직접 사용하지 않습니다.


AppHost 패턴 (명시적 매핑)

예제: 데이터베이스 + Blob 스토리지

// AppHost/Program.cs
var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres");
var db = postgres.AddDatabase("appdb");

var minio = builder.AddContainer("minio", "minio/minio")
    .WithArgs("server", "/data")
    .WithHttpEndpoint(targetPort: 9000, name: "http")
    .WithHttpEndpoint(targetPort: 9001, name: "console")
    .WithEnvironment("MINIO_ROOT_USER", "minioadmin")
    .WithEnvironment("MINIO_ROOT_PASSWORD", "minioadmin");

var api = builder.AddProject<Projects.MyApp_Api>("api")
    .WithReference(db, "Postgres")
    .WithEnvironment("BlobStorage__Enabled", "true")
    .WithEnvironment("BlobStorage__ServiceUrl", minio.GetEndpoint("http"))
    .WithEnvironment("BlobStorage__AccessKey", "minioadmin")
    .WithEnvironment("BlobStorage__SecretKey", "minioadmin")
    .WithEnvironment("BlobStorage__Bucket", "attachments")
    .WithEnvironment("BlobStorage__ForcePathStyle", "true");

builder.Build().Run();

핵심 사항

  • WithReference(db, "Postgres")는 ConnectionStrings__Postgres를 명시적으로 설정합니다.
  • 모든 외부 종속성은 명시적인 구성 키를 통해 표현됩니다.
  • API 프로젝트는 Configuration 값만 읽습니다.

앱 코드 패턴 (Aspire 클라이언트 없음)

애플리케이션 코드는 옵션에 바인딩되고 SDK를 직접 초기화합니다. Aspire 클라이언트 패키지나 서비스 검색에 절대 의존하지 않습니다.

// Api/Program.cs
builder.Services
    .AddOptions<BlobStorageOptions>()
    .BindConfiguration("BlobStorage")
    .ValidateDataAnnotations()
    .ValidateOnStart();

builder.Services.AddSingleton<IBlobStorageService>(sp =>
{
    var options = sp.GetRequiredService<IOptions<BlobStorageOptions>>().Value;
    return new S3BlobStorageService(options); // 명시적 옵션만 사용
});

앱에 Aspire 클라이언트 패키지(또는 AddServiceDiscovery)를 추가하지 마십시오. 이러한 것은 오케스트레이션 관련 사항이므로 AppHost에 남아 있어야 합니다.


기능 토글 및 테스트 재정의

토글을 구성에 유지하고 AppHost와 테스트 픽스처를 통해 제어하세요. 이렇게 하면 개발/테스트와 프로덕션 구성 간의 동등성이 유지됩니다.

// AppHost: 구성 재정의를 통해 테스트에서 지속성 비활성화
var config = builder.Configuration.GetSection("App")
    .Get<AppHostConfiguration>() ?? new AppHostConfiguration();

if (!config.UseVolumes)
{
    postgres.WithDataVolume(false);
}

api.WithEnvironment("BlobStorage__Enabled", config.EnableBlobStorage.ToString());

DistributedApplicationTestingBuilder에 구성 재정의를 전달하는 패턴은 skills/aspire/integration-testing/SKILL.md를 참조하세요.


수행/금지 목록

수행

  • 모든 Aspire 리소스 출력을 명시적인 구성 키로 매핑하세요
  • 모든 인프라 설정에 대해 유효성 검사와 함께 IOptions<T>를 사용하세요
  • Aspire 호스팅 패키지를 참조하는 유일한 위치로 AppHost를 유지하세요
  • AppHost가 주입하는 모든 값이 프로덕션 환경 변수로 설정될 수 있는지 확인하세요

금지

  • 애플리케이션 프로젝트에서 Aspire 클라이언트/서비스 검색 패키지를 참조하지 마세요
  • 프로덕션에서 미러링할 수 없는 불투명한 서비스 검색에 의존하지 마세요
  • Aspire 전용 추상화 뒤에 구성을 숨기지 마세요

관련 스킬

  • skills/aspire/service-defaults/SKILL.md
  • skills/aspire/integration-testing/SKILL.md
  • skills/akka/aspire-configuration/SKILL.md

리소스

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

akka-hosting-actor-patterns

Patterns for building entity actors with Akka.Hosting - GenericChildPerEntityParent, message extractors, cluster sharding abstraction, akka-reminders, and ITimeProvider. Supports both local testing and clustered production modes.

akka-net-aspire-configuration

Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering, persistence, Akka.Management integration, and Aspire orchestration patterns.

akka-net-best-practices

Critical Akka.NET best practices including EventStream vs DistributedPubSub, supervision strategies, error handling, Props vs DependencyResolver, work distribution patterns, and cluster/local mode abstractions for testability.

akka-net-management

Akka.Management for cluster bootstrapping, service discovery (Kubernetes, Azure, Config), health checks, and dynamic cluster formation without static seed nodes.

akka-net-testing-patterns

Write unit and integration tests for Akka.NET actors using modern Akka.Hosting.TestKit patterns. Covers dependency injection, TestProbes, persistence testing, and actor interaction verification. Includes guidance on when to use traditional TestKit.

api-design

Design stable, compatible public APIs using extend-only design principles. Manage API compatibility, wire compatibility, and versioning for NuGet packages and distributed systems.

aspire-integration-testing

Write integration tests using .NET Aspire

aspire-service-defaults

Create a shared ServiceDefaults project for Aspire applications. Centralizes OpenTelemetry, health checks, resilience, and service discovery configuration across all services.

crap-analysis

Analyze code coverage and CRAP (Change Risk Anti-Patterns) scores to identify high-risk code. Use OpenCover format with ReportGenerator for Risk Hotspots showing cyclomatic complexity and untested code paths.

csharp-concurrency-patterns

Choosing the right concurrency abstraction in .NET - from async/await for I/O to Channels for producer/consumer to Akka.NET for stateful entity management. Avoid locks and manual synchronization unless absolutely necessary.

database-performance

Database access patterns for performance. Separate read/write models, avoid N+1 queries, use AsNoTracking, apply row limits, and never do application-side joins. Works with EF Core and Dapper.

dependency-injection-patterns

Organize DI registrations using IServiceCollection extension methods. Group related services into composable Add* methods for clean Program.cs and reusable configuration in tests.

dotnet-devcert-trust

Diagnose and fix .NET HTTPS dev certificate trust issues on Linux. Covers the full certificate lifecycle from generation to system CA bundle inclusion, with distro-specific guidance for Ubuntu, Fedora, Arch, and WSL2.

dotnet-local-tools

Managing local .NET tools with dotnet-tools.json for consistent tooling across development environments and CI/CD pipelines.

dotnet-project-structure

Modern .NET project structure including .slnx solution format, Directory.Build.props, central package management, SourceLink, version management with RELEASE_NOTES.md, and SDK pinning with global.json.

dotnet-slopwatch

Use Slopwatch to detect LLM reward hacking in .NET code changes. Run after every code modification to catch disabled tests, suppressed warnings, empty catch blocks, and other shortcuts that mask real problems.

efcore-patterns

Entity Framework Core best practices including NoTracking by default, query splitting for navigation collections, migration management, dedicated migration services, and common pitfalls to avoid.

ilspy-decompile

Understand implementation details of .NET code by decompiling assemblies. Use when you want to see how a .NET API works internally, inspect NuGet package source, view framework implementation, or understand compiled .NET binaries.

mailpit-integration

Test email sending locally using Mailpit with .NET Aspire. Captures all outgoing emails without sending them. View rendered HTML, inspect headers, and verify delivery in integration tests.

marketplace-publishing

Workflow for publishing skills and agents to the dotnet-skills Claude Code marketplace. Covers adding new content, updating plugin.json, validation, and release tagging.

관련 스킬