Portal Community

Step 1 — Package Reference

<!-- Add to your Octopus host project's .csproj -->
<PackageReference Include="BizFirst.Octopus.SqlServerPlugin" Version="*" />

Step 2 — Register in Program.cs

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

builder.Services.AddOctopus(config =>
{
    // SqlServerPlugin MUST be the first plugin registered.
    // All other plugins depend on the services it provides
    // (OctopusDbContext, IAgentStore, IEpisodicMemoryStore, etc.)
    config.AddPlugin<SqlServerPlugin>();

    // Other plugins follow
    config.AddPlugin<SemanticKernelPlugin>();
    config.AddPlugin<ChatbotUIPlugin>();
    config.AddPlugin<ProcessPlugin>();
});

var app = builder.Build();
app.UseOctopus();
app.Run();

Step 3 — appsettings.json Configuration

{
  "SqlServerPlugin": {
    "ConnectionStringCredentialId": 1,
    "CommandTimeoutSeconds": 30,
    "EnableRetryOnFailure": true,
    "MaxRetryCount": 3,
    "MaxRetryDelaySeconds": 30,
    "RunMigrationsOnStartup": true,
    "MigrationTimeout": 120
  }
}
SettingTypeDefaultDescription
ConnectionStringCredentialIdint— (required)Credential ID for the SQL Server connection string
CommandTimeoutSecondsint30EF Core command timeout for individual queries
EnableRetryOnFailurebooltrueEnables Polly-backed transient fault retry
MaxRetryCountint3Retry attempts before propagating the exception
MaxRetryDelaySecondsint30Max delay between retries (exponential backoff)
RunMigrationsOnStartupbooltrueWhether to run pending EF Core migrations automatically
MigrationTimeoutint120Seconds to allow for migration on startup

Credential Setup

The connection string is stored as a credential — never in appsettings.json directly. Register it once via the Octopus admin API:

POST /api/credentials
Content-Type: application/json

{
  "name":        "OctopusSqlServer",
  "description": "Connection string for Octopus SQL Server database",
  "type":        "ConnectionString",
  "value":       "Server=sql.internal.company.com;Database=OctopusAI;Integrated Security=True;TrustServerCertificate=True;"
}
// Response:
{
  "id":   1,
  "name": "OctopusSqlServer"
}

// Use the returned id as ConnectionStringCredentialId in appsettings.json

Verifying the Setup

On a successful startup, the application log will contain the following lines in order:

[SqlServerPlugin] Resolving connection string from credential 1
[SqlServerPlugin] Connection to OctopusAI verified
[SqlServerPlugin] Running pending EF Core migrations...
[SqlServerPlugin] Applied migration: 20240101_InitialOctopusSchema
[SqlServerPlugin] Applied migration: 20240615_AddAreaTables
[SqlServerPlugin] Database schema is up to date
[SqlServerPlugin] Startup complete — all Octopus SQL services available
Cold start time. On first deployment, migrations create all tables and indexes. This can take 5–30 seconds depending on SQL Server load. Subsequent startups are fast — only pending migrations run.