Table of Contents

Class CloudEnvironment

Namespace
CobaltPdf
Assembly
CobaltPdf.dll

Provides ready-made PoolOptions presets for common cloud and container deployment targets.

public static class CloudEnvironment
Inheritance
CloudEnvironment
Inherited Members

Remarks

Use one of the static Configure* methods inside Configure(Action<PoolOptions>) to apply the recommended settings for your environment in a single call:

CobaltEngine.Configure(CloudEnvironment.ConfigureForDocker);

All presets can be further customized after the preset has been applied:

CobaltEngine.Configure(o =>
{
    CloudEnvironment.ConfigureForDocker(o);
    o.MaxSize = 4;          // override the default pool ceiling
    o.ExtraArgs.Add("--proxy-server=host:port"); // add extra flags
});

Fields

DisableDevShm

--disable-dev-shm-usage — required in Docker containers with a small /dev/shm (the default on most container runtimes).

public const string DisableDevShm = "--disable-dev-shm-usage"

Field Value

string

DisableGpu

--disable-gpu — suppresses GPU errors on headless servers that have no GPU.

public const string DisableGpu = "--disable-gpu"

Field Value

string

NoSandbox

--no-sandbox — required in all Linux environments.

public const string NoSandbox = "--no-sandbox"

Field Value

string

SingleProcess

--single-process — merges browser and renderer into a single OS process. ⚠ Not recommended. It lowers memory but breaks PDF rendering of multi-page / non-trivial documents (the renderer crashes mid-print), so it is no longer used by any preset. Exposed only for advanced manual use on a single short page you've verified.

public const string SingleProcess = "--single-process"

Field Value

string

Methods

ConfigureForAwsEcs(PoolOptions)

Configures options for AWS ECS (Fargate or EC2-backed tasks).

public static void ConfigureForAwsEcs(PoolOptions options)

Parameters

options PoolOptions

Remarks

Applies: --no-sandbox, --disable-dev-shm-usage, --disable-gpu. Pool sizing: MinSize = 1, MaxSize = ProcessorCount / 2 (min 1).

ConfigureForAzure(PoolOptions)

Configures options for an Azure App Service or Azure Functions Premium Plan running on Linux.

public static void ConfigureForAzure(PoolOptions options)

Parameters

options PoolOptions

Remarks

Azure App Service Linux containers expose limited /dev/shm, so both --disable-dev-shm-usage and --no-sandbox are required.

Applies: --no-sandbox, --disable-dev-shm-usage, --disable-gpu. Pool sizing: MinSize = 1, MaxSize = ProcessorCount / 2 (min 1).

⚠ The Consumption Plan is not supported. Use the Premium Plan or Dedicated (App Service) Plan so that the browser pool can persist between invocations. See the Deployment guide.

ConfigureForDocker(PoolOptions)

Configures options for a Docker container.

public static void ConfigureForDocker(PoolOptions options)

Parameters

options PoolOptions

Remarks

Applies: --no-sandbox, --disable-dev-shm-usage, --disable-gpu. Pool sizing: MinSize = 1, MaxSize = ProcessorCount / 2 (min 1).

Important: Do not use --self-contained or -r <RID> flags when building. Both flatten the runtimes/{rid}/native/ folder structure, which prevents Chromium.Path from locating the Chromium binary at runtime. Use dotnet build or dotnet publish without the -r flag.

ConfigureForLinux(PoolOptions)

Configures options for a standard Linux host (bare metal or VM).

public static void ConfigureForLinux(PoolOptions options)

Parameters

options PoolOptions

Remarks

Applies: --no-sandbox, --disable-gpu. Pool sizing: MinSize = 1, MaxSize = ProcessorCount / 2 (min 1).

ConfigureForLowMemory(PoolOptions)

Configures options for a memory-constrained environment (e.g. AWS Lambda via a custom runtime container, small VMs).

public static void ConfigureForLowMemory(PoolOptions options)

Parameters

options PoolOptions

Remarks

Applies: --no-sandbox, --disable-dev-shm-usage, --disable-gpu. Pool sizing: MinSize = 0 (lazy — nothing kept warm), MaxSize = 1 (one render at a time), which keeps idle memory minimal.

Note: this preset does not use --single-process. Although that flag lowers memory further, it crashes the renderer on multi-page / non-trivial PDFs, so it is not safe for a general-purpose PDF workload.