Orchardcore configuration

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore configuration is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for configuring Orchard Core applications. Covers IShellConfiguration, configuration sources hierarchy, the Orchard Core 4.0 section names grouped by service (Email Smtp, Media Azure, Search Elasticsearch) and the deprecated OrchardCore_ prefixed names, environment variable and Azure Key Vault

How to use this skill

Skill file

Orchard Core Configuration - Prompt Templates

Configure Orchard Core Applications

You are an Orchard Core expert. Generate configuration JSON, environment variables, and C# code for Orchard Core application settings, tenant configuration, and IOptions overrides.

Guidelines

Configuration Sources Hierarchy

Configuration is loaded in the following order (last wins):

  1. Startup project appsettings.json
  2. Startup project appsettings.{Environment}.json
  3. User Secrets (Development environment only)
  4. Environment variables (including Azure App Settings)
  5. Command line arguments
  6. App_Data/appsettings.json (global tenant configuration, IShellConfiguration only)
  7. App_Data/Sites/{tenant_name}/appsettings.json (per-tenant configuration, IShellConfiguration only)

Configuration Section Names (Orchard Core 4.0)

Common sections, all nested under OrchardCore:

| Area | Section |

| --- | --- |

| Admin | Admin, Admin:List |

| Email | Email:Smtp, Email:Azure |

| SMS | Sms:Azure |

| Media | Media, Media:Azure, Media:Azure:ImageCache, Media:AmazonS3, Media:AmazonS3:ImageCache, Media:Slugify |

| Search | Search:Elasticsearch, Search:AzureAISearch |

| Authentication | Authentication:GitHub, Authentication:Google, Authentication:AzureAD, Authentication:MicrosoftAccount, Facebook, X |

| Data | Data:Sqlite, Data:TableOptions, YesSql, Documents |

| Hosting | Shells:Azure, Shells:Database, KeyVault:Azure, DataProtection:Azure, Redis, BackgroundService, TempDirectory |

| Other | Tenants, Users, Roles, Security, Setup, AutoSetup, Liquid, Markdown, Resources, ReverseProxy, HealthChecks, DynamicCache, Workflows, Apis:GraphQL, ReCaptcha, Navigation, Notifications, ContentTypes, Localization:CultureOptions, ContentLocalization:CulturePickerOptions, Antivirus:ClamAV |

See references/configuration-section-names.md for the full previous → new rename table, environment variable and Key Vault before/after examples.

{
  "OrchardCore": {
    "Email": {
      "Smtp": {
        "DefaultSender": "site@example.com"
      }
    },
    "Media": {
      "MaxFileSize": 104857600,
      "Azure": {
        "ConnectionString": "...",
        "ContainerName": "media",
        "ImageCache": {
          "ContainerName": "imagecache"
        }
      }
    },
    "Search": {
      "Elasticsearch": {
        "Url": "http://localhost:9200"
      }
    },
    "BackgroundService": {
      "ShellWarmup": true,
      "PollingTime": "00:01:00",
      "MinimumIdleTime": "00:00:10"
    }
  }
}

Upgrading from 3.x

IntelliSense and Validation of appsettings.json

Orchard Core packages that read a configuration section ship a ConfigurationSchema.json file declared as a JSON schema segment. It flows to referencing projects (for example through OrchardCore.Application.Cms.Targets), so Visual Studio provides IntelliSense, descriptions, known values (database providers, setup recipes, time zones, cultures, AWS regions, security headers), and flags deprecated section names in:

Tenant files under App_Data/Sites/{tenant}/ get no IntelliSense (their sections are not nested in OrchardCore), and Visual Studio Code does not support JSON schema segments yet.

A module can describe its own sections the same way: put a ConfigurationSchema.json at the package root describing properties under OrchardCore, and declare it in buildTransitive/{PackageId}.targets:

<Project>
  <ItemGroup>
    <JsonSchemaSegment Include="$(MSBuildThisFileDirectory)..\ConfigurationSchema.json" FilePathPattern="appsettings\..*json" />
  </ItemGroup>
</Project>
{
  "type": "object",
  "properties": {
    "OrchardCore": {
      "type": "object",
      "properties": {
        "MyService": {
          "type": "object",
          "description": "Settings of My Service.",
          "properties": {
            "ApiKey": {
              "type": "string",
              "description": "The API key. Provide it through user secrets, environment variables or a key vault."
            }
          }
        },
        "MyCompany_MyService": {
          "type": "object",
          "deprecated": true,
          "deprecationMessage": "The 'MyCompany_MyService' section is deprecated. Use 'OrchardCore:MyService' instead.",
          "doNotSuggest": true
        }
      }
    }
  }
}

Naming Sections in Your Own Modules

Follow the same convention: no OrchardCore_ prefix, grouped by service, e.g. OrchardCore:MyService:MyProvider (environment variable OrchardCore__MyService__MyProvider__MySetting).

To rename an existing section without breaking deployments, bind through GetSectionCompat(key, params legacyKeys) from OrchardCore.Environment.Shell.Configuration. It returns a section merged key by key with its legacy sections: the new key wins, then legacy keys in the order given; arrays in a higher-priority section replace lower ones; underscore legacy keys also resolve their dot-notation form.

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Environment.Shell.Configuration;
using OrchardCore.Modules;

namespace MyCompany.MyService;

public sealed class Startup : StartupBase
{
    private readonly IShellConfiguration _shellConfiguration;

    public Startup(IShellConfiguration shellConfiguration)
    {
        _shellConfiguration = shellConfiguration;
    }

    public override void ConfigureServices(IServiceCollection services)
    {
        // 'MyCompany_MyService' is deprecated, use 'MyService' instead.
        services.Configure<MyServiceOptions>(
            _shellConfiguration.GetSectionCompat("MyService", "MyCompany_MyService"));
    }
}

The single-argument GetSectionCompat(key) overload only adds the old dot-notation fallback and should not be used for new code.

Tenant Pre-Configuration

Pre-configure a tenant before it is created. The tenant appears in the admin Tenants list with these values pre-filled:

{
  "OrchardCore": {
    "MyTenant": {
      "State": "Uninitialized",
      "RequestUrlPrefix": "mytenant",
      "ConnectionString": "Server=localhost;Database=MyTenantDb;Trusted_Connection=True;",
      "DatabaseProvider": "SqlConnection"
    }
  }
}

Tenant Post-Configuration

Override module settings for a specific tenant after it has been set up:

{
  "OrchardCore": {
    "Default": {
      "Media": {
        "MaxFileSize": 209715200
      }
    }
  }
}

Global Tenant Database Configuration

Configure all tenants to share the same database from a single configuration block:

{
  "OrchardCore": {
    "ConnectionString": "Server=localhost;Database=SharedOrchardDb;Trusted_Connection=True;",
    "DatabaseProvider": "SqlConnection",
    "Tenants": {
      "RequireTablePrefix": true,
      "TablePrefixPattern": "{{ ShellSettings.Name }}",
      "SchemaPattern": "dbo"
    },
    "Default": {
      "State": "Uninitialized",
      "TablePrefix": "Default"
    }
  }
}

Per-Tenant Configuration File

Tenant-specific files at App_Data/Sites/{tenant_name}/appsettings.json omit the OrchardCore wrapper. They are written during setup, so environment-specific variants are not supported:

{
  "Media": {
    "MaxFileSize": 52428800
  }
}

Environment Variable Overrides

OrchardCore__Media__MaxFileSize=104857600
OrchardCore__Default__Media__MaxFileSize=209715200
OrchardCore__MyTenant__Media__MaxFileSize=52428800
OrchardCore__Email__Smtp__DefaultSender=noreply@example.com
OrchardCore__Media__Azure__ConnectionString=DefaultEndpointsProtocol=https;...

The 4.0 names keep variable names short, which matters for hosts that limit their length.

Azure Key Vault Secret Names

With AddOrchardCoreAzureKeyVault() (configured under OrchardCore:KeyVault:Azure), secret names map -- to : and --- to _:

| Secret name | Configuration key |

| --- | --- |

| OrchardCore--Media--Azure--ConnectionString | OrchardCore:Media:Azure:ConnectionString |

| OrchardCore--Shells--Database--ConnectionString | OrchardCore:Shells:Database:ConnectionString |

Temporary File Storage

Orchard Core writes in-progress chunked and TUS uploads, deployment and recipe import/export archives, and tenant recipe uploads under a tenant-scoped sub-directory of OrchardCore:TempDirectory:Path (default: the OS temp directory). Point it at a mounted file share, not object storage:

{
  "OrchardCore": {
    "TempDirectory": {
      "Path": "/mnt/shared/temp"
    }
  }
}

Module code should inject ITempDirectoryProvider (GetRootDirectory(), GetTempFileName(extension), CreateTempSubdirectory(prefix)) instead of calling Path.GetTempPath(). See orchardcore-temp-file-storage for details.

Overriding IOptions from Startup

Use PostConfigure to override values populated from site settings:

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddOrchardCms()
    .ConfigureServices(tenantServices =>
        tenantServices.PostConfigure<ResourceOptions>(options =>
        {
            options.UseCdn = true;
        }));

var app = builder.Build();
app.UseStaticFiles();
app.UseOrchardCore();
app.Run();

The admin settings screen still shows the stored site settings value, so tell administrators when a value is overridden from code.

Using IShellConfiguration in PostConfigure

Read values from the tenant-aware configuration hierarchy (prefer IShellConfiguration over IConfiguration so App_Data and tenant files are included):

var builder = WebApplication.CreateBuilder(args);

builder.Services
    .AddOrchardCms()
    .ConfigureServices((tenantServices, serviceProvider) =>
    {
        var shellConfiguration = serviceProvider.GetRequiredService<IShellConfiguration>();

        tenantServices.PostConfigure<ResourceOptions>(options =>
        {
            options.UseCdn = shellConfiguration.GetValue<bool>("Resources:UseCdn");
        });
    });

var app = builder.Build();
app.UseStaticFiles();
app.UseOrchardCore();
app.Run();

Live Tenant Options with IOptionsMonitor

Orchard Core 4.0 adds a post-commit, signal-backed refresh pipeline for options built from mutable tenant state (site settings, documents). Built-in examples: EmailOptions, EmailProviderOptions, AzureEmailOptions, SmtpOptions, ShapeRenderingOptions, ReCaptchaSettings, RegistrationOptions, ExternalLoginOptions, AzureAISearchDefaultOptions, SmsProviderOptions, AzureSmsOptions, TwilioOptions, AdminListOptions.

See orchardcore-site-settings for a complete settings-backed options example.

Custom App_Data Location

Set the ORCHARD_APP_DATA environment variable to change the data folder (created if missing):

ORCHARD_APP_DATA=D:\OrchardData\App_Data

Supported path formats: relative (./App_Data), absolute (/path/from/root), or fully qualified (D:\Path\To\App_Data).

Azure Deployment Configuration

Azure App Settings are treated as environment variables:

| Azure App Setting | Value |

|---|---|

| OrchardCore__Media__MaxFileSize | 104857600 |

| OrchardCore__Default__Email__Smtp__DefaultSender | noreply@example.com |

For CI/CD pipelines, use JSON path transformations to inject secrets from pipeline variables or Azure Key Vault into appsettings.json. The IShellConfiguration files in App_Data can also be stored in Azure Blob Storage or the database (see orchardcore-shells).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.