OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.45k stars 2.41k forks source link

Add the ability to specify Feature Profiles from IOptions (configuration provider) #12981

Open Piedone opened 1 year ago

Piedone commented 1 year ago

Is your feature request related to a problem? Please describe.

Tenant feature profiles are stored in a single document in the DB. While this makes it possible to change the configuration from the admin, it also necessitates this. Having environment-specific configuration is thus hard to achieve, and getting changes implemented during development time out to a production environment needs either manual updates or something like migrations.

Describe the solution you'd like

This suggestion is about adding the ability to, in addition to the existing DB-based admin configuration, set this configuration from configuration providers. I.e., do what e.g. OrchardCore.Email does with SmtpSettings:

Describe alternatives you've considered

Workarounds like the mentioned migrations approach are available, but to set such configuration in a flexible manner, the one approach is really such a configuration provider-based approach.

rjpowers10 commented 1 year ago

A good example is Lombiq.Hosting.Azure.ApplicationInsights. I'd like to enable this in prod but not in staging.

Piedone commented 1 year ago

Note that Feature Profiles are about allowing certain modules/features for certain tenants, not about enabling them. You need Feature Profiles if you want admin users of given tenants to not see certain modules.

However, if you want to conditionally enable a feature, you can do that along these lines in your Program.cs:

var builder = WebApplication.CreateBuilder(args);

...

builder.Services
    .AddOrchardCms(orchardCoreBuilder =>
    {
        if (...)
        {
            orchardCoreBuilder.AddTenantFeatures("Lombiq.Hosting.Azure.ApplicationInsights");
        }
    });

And thanks for using our module!

rjpowers10 commented 1 year ago

Note that Feature Profiles are about allowing certain modules/features for certain tenants, not about enabling them. You need Feature Profiles if you want admin users of given tenants to not see certain modules.

However, if you want to conditionally enable a feature, you can do that along these lines in your Program.cs:

var builder = WebApplication.CreateBuilder(args);

...

builder.Services
    .AddOrchardCms(orchardCoreBuilder =>
    {
        if (...)
        {
            orchardCoreBuilder.AddTenantFeatures("Lombiq.Hosting.Azure.ApplicationInsights");
        }
    });

And thanks for using our module!

Excellent! Thanks for the clarification and thanks for the module!