jpskill.com
📦 その他 コミュニティ

aspire-configuration

Aspire AppHostの設定を通じて、アプリケーション設定を環境変数として明示的に出力し、アプリケーションのコードからAspireクライアントやサービスディスカバリに関する記述を分離することで、より柔軟で管理しやすい構成にするSkill。

📜 元の英語説明(参考)

Configure Aspire AppHost to emit explicit app config via environment variables; keep app code free of Aspire clients and service discovery.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Aspire AppHostの設定を通じて、アプリケーション設定を環境変数として明示的に出力し、アプリケーションのコードからAspireクライアントやサービスディスカバリに関する記述を分離することで、より柔軟で管理しやすい構成にするSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o aspire-configuration.zip https://jpskill.com/download/8700.zip && unzip -o aspire-configuration.zip && rm aspire-configuration.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/8700.zip -OutFile "$d\aspire-configuration.zip"; Expand-Archive "$d\aspire-configuration.zip" -DestinationPath $d -Force; ri "$d\aspire-configuration.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して aspire-configuration.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → aspire-configuration フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Aspire の構成

この Skill を使用する場面

この Skill は、以下のような場合に使用します。

  • Aspire ベースのリポジトリで、AppHost のリソースをアプリケーション構成に接続する場合
  • Aspire の外部で、本番環境の構成が透過的かつ移植可能であることを保証する場合
  • アプリケーションコード内で、Aspire のクライアント/サービスディスカバリーパッケージを使用しないようにする場合
  • アプリケーションコードのパスを変更せずに、開発/テスト用のフィーチャートグルを設計する場合

中核となる原則

  1. AppHost が Aspire インフラストラクチャパッケージを所有する

    • Aspire Hosting パッケージは、AppHost のみに存在します。
    • アプリケーションプロジェクトは、Aspire のクライアント/サービスディスカバリーパッケージを参照すべきではありません。
  2. 明示的な構成のみ

    • AppHost は、リソースの出力を明示的な構成キー(環境変数)に変換する必要があります。
    • アプリケーションコードは、IOptions<T> または Configuration のみにバインドします。
  3. 本番環境との同等性と透明性

    • AppHost によって注入されるすべての値は、Aspire なしで、環境変数または構成ファイルとして本番環境で表現できる必要があります。
    • 不透明なサービスディスカバリーと暗黙的な構成は避けてください。

構成の流れ

AppHost リソース -> WithEnvironment(...) -> アプリ構成キー -> アプリ内の IOptions<T>

AppHost は、Aspire のリソースを明示的なアプリケーション設定に変換する役割を担います。 アプリケーションは、Aspire のクライアントやサービスディスカバリーを直接使用することはありません。


AppHost のパターン(明示的なマッピング)

例:データベース + Blob Storage

// 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 を参照してください。


Do / Don’t チェックリスト

Do

  • すべての Aspire リソース出力を明示的な構成キーにマッピングする
  • すべてのインフラストラクチャ設定に、検証付きの IOptions<T> を使用する
  • AppHost を、Aspire ホスティングパッケージを参照する唯一の場所として維持する
  • AppHost によって注入されたすべての値が、本番環境の環境変数で設定できることを確認する

Don’t

  • アプリケーションプロジェクトで Aspire クライアント/サービスディスカバリーパッケージを参照する
  • 本番環境でミラーリングできない不透明なサービスディスカバリーに依存する
  • Aspire 専用の抽象化の背後に構成を隠す

関連 Skill

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

リソース

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Aspire Configuration

When to Use This Skill

Use this skill when:

  • Wiring AppHost resources to application configuration in Aspire-based repos
  • Ensuring production configuration is transparent and portable outside of Aspire
  • Avoiding Aspire client/service-discovery packages inside application code
  • Designing feature toggles for dev/test without changing app code paths

Core Principles

  1. AppHost owns Aspire infrastructure packages

    • Aspire Hosting packages belong in AppHost only.
    • App projects should not reference Aspire client/service-discovery packages.
  2. Explicit configuration only

    • AppHost must translate resource outputs into explicit config keys (env vars).
    • App code binds to IOptions<T> or Configuration only.
  3. Production parity and transparency

    • Every value injected by AppHost must be representable in production as env vars or config files without Aspire.
    • Avoid opaque service discovery and implicit configuration.

Configuration Flow

AppHost resource -> WithEnvironment(...) -> app config keys -> IOptions<T> in app

The AppHost is responsible for turning Aspire resources into explicit app settings. The application never consumes Aspire clients or service discovery directly.


AppHost Patterns (Explicit Mapping)

Example: Database + Blob Storage

// 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();

Key points

  • WithReference(db, "Postgres") sets ConnectionStrings__Postgres explicitly.
  • Every external dependency is represented via explicit config keys.
  • The API project only reads Configuration values.

App Code Pattern (No Aspire Clients)

Application code binds to options and initializes SDKs directly. It never depends on Aspire client packages or service discovery.

// 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); // uses explicit options only
});

Do not add Aspire client packages (or AddServiceDiscovery) to the app. Those are orchestration concerns and should stay in AppHost.


Feature Toggles and Test Overrides

Keep toggles in config and drive them through AppHost and test fixtures. This maintains parity between dev/test and production configuration.

// AppHost: disable persistence in tests via config overrides
var config = builder.Configuration.GetSection("App")
    .Get<AppHostConfiguration>() ?? new AppHostConfiguration();

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

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

See skills/aspire/integration-testing/SKILL.md for patterns on passing configuration overrides into DistributedApplicationTestingBuilder.


Do / Don’t Checklist

Do

  • Map every Aspire resource output to explicit configuration keys
  • Use IOptions<T> with validation for all infrastructure settings
  • Keep AppHost as the only place that references Aspire hosting packages
  • Ensure any AppHost-injected value can be set in production env vars

Don’t

  • Reference Aspire client/service-discovery packages in application projects
  • Rely on opaque service discovery that cannot be mirrored in production
  • Hide configuration behind Aspire-only abstractions

Related Skills

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

Resources