Skip to content

Conversation

Copy link

Copilot AI commented Dec 31, 2025

Adds Aspire.Com.Ctrip.Framework.Apollo.Configuration package to enable .NET Aspire applications to integrate with Apollo Configuration Center with comprehensive configuration options support.

Implementation

  • ApolloResource: Complete resource definition for Apollo configuration servers in Aspire's application model with support for all Apollo.NET configuration options:

    • Basic: AppId, MetaServer, Env, Cluster, DataCenter
    • Authentication: Secret
    • Networking: ConfigServer (direct URLs), Meta (environment-specific servers)
    • Behavior: Timeout, RefreshInterval, LocalCacheDir, Label
    • Configuration: Namespaces
  • ApolloResourceBuilderExtensions:

    • AddApollo(): Registers Apollo as a configuration resource
    • Fluent API methods for all configuration options: WithAppId(), WithMetaServer(), WithEnvironment(), WithCluster(), WithDataCenter(), WithSecret(), WithConfigServer(), WithNamespaces(), WithTimeout(), WithRefreshInterval(), WithLocalCacheDir(), WithMeta(), WithLabel()
    • WithReference(): Binds Apollo to services via environment variables with full configuration mapping
  • Package targets .NET 9.0, depends on Aspire.Hosting 9.0.0 and Apollo.Configuration

Usage

Basic Usage

var builder = DistributedApplication.CreateBuilder(args);

var apollo = builder.AddApollo("apollo", 
    appId: "MyApp",
    metaServer: "http://localhost:8080");

var myService = builder.AddProject<Projects.MyService>("myservice")
                       .WithReference(apollo, namespaces: new[] { "application", "database" });

builder.Build().Run();

Advanced Configuration

var builder = DistributedApplication.CreateBuilder(args);

var apollo = builder.AddApollo("apollo")
    .WithAppId("SampleApp")
    .WithMetaServer("http://localhost:8080")
    .WithEnvironment("PRO")  // DEV, FAT, UAT, PRO
    .WithCluster("default")
    .WithDataCenter("us-west")
    .WithSecret("your-secret-key")
    .WithNamespaces("application", "database.config", "redis.config")
    .WithTimeout(5000)
    .WithRefreshInterval(300000);

var myService = builder.AddProject<Projects.MyService>("myservice")
                       .WithReference(apollo);

builder.Build().Run();

Services automatically receive Apollo configuration through environment variables (e.g., Apollo__AppId, Apollo__MetaServer, Apollo__Env, Apollo__Cluster, Apollo__Secret, etc.), compatible with existing Apollo.Configuration client library.

Configuration Options Supported

All Apollo.NET configuration options are supported including:

  • Environment, Cluster, DataCenter
  • Secret for authentication
  • ConfigServer for skipping meta service discovery
  • Timeout and RefreshInterval for performance tuning
  • LocalCacheDir for cache management
  • Meta for environment-specific meta servers
  • Label for configuration versioning
  • Namespaces for loading specific configurations
Original prompt

This section details on the original issue you should resolve

<issue_title>Aspire中集成Apollo</issue_title>
<issue_description>能不能开发一个Aspire集成的包Aspire.Com.Ctrip.Framework.Apollo.Configuration</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link

coderabbitai bot commented Dec 31, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 2 commits December 31, 2025 03:03
Co-authored-by: pengweiqhca <3982826+pengweiqhca@users.noreply.github.com>
Co-authored-by: pengweiqhca <3982826+pengweiqhca@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Aspire integration package for Apollo Add Aspire hosting integration for Apollo Configuration Center Dec 31, 2025
Copilot AI requested a review from pengweiqhca December 31, 2025 03:09
/// <param name="name">The name of the resource.</param>
/// <param name="appId">The Apollo application ID.</param>
/// <param name="metaServer">The Apollo meta server URL.</param>
public class ApolloResource(string name, string? appId, string? metaServer) : Resource(name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many options are missing, see REAMDE.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added all missing Apollo configuration options from the README. The implementation now supports:

  • Environment (Env), Cluster, DataCenter
  • Secret for authentication
  • ConfigServer for direct URLs
  • Timeout, RefreshInterval, LocalCacheDir
  • Meta for environment-specific servers
  • Label and Namespaces

All options are exposed through fluent API methods (WithEnvironment, WithCluster, WithSecret, etc.) and properly mapped to environment variables. See commit 83e88fc.

Copilot AI and others added 2 commits January 1, 2026 06:38
Co-authored-by: pengweiqhca <3982826+pengweiqhca@users.noreply.github.com>
Co-authored-by: pengweiqhca <3982826+pengweiqhca@users.noreply.github.com>
Copilot AI changed the title Add Aspire hosting integration for Apollo Configuration Center Add Aspire hosting integration for Apollo Configuration Center with full configuration support Jan 1, 2026
Copilot AI requested a review from pengweiqhca January 1, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Aspire中集成Apollo

2 participants