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 customised 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
DisableGpu
--disable-gpu — suppresses GPU errors on headless servers that have no GPU.
public const string DisableGpu = "--disable-gpu"
Field Value
NoSandbox
--no-sandbox — required in all Linux environments.
public const string NoSandbox = "--no-sandbox"
Field Value
SingleProcess
--single-process — merges browser and renderer into a single OS process.
Reduces memory usage at the cost of slightly lower stability. Suitable for
memory-constrained environments such as AWS Lambda or small container instances.
public const string SingleProcess = "--single-process"
Field Value
Methods
ConfigureForAwsEcs(PoolOptions)
Configures options for AWS ECS (Fargate or EC2-backed tasks).
public static void ConfigureForAwsEcs(PoolOptions options)
Parameters
optionsPoolOptions
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
optionsPoolOptions
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,
--single-process.
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
optionsPoolOptions
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
optionsPoolOptions
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
optionsPoolOptions
Remarks
Applies: --no-sandbox, --disable-dev-shm-usage, --disable-gpu,
--single-process.
Pool sizing: MinSize = 0 (lazy), MaxSize = 1.
--single-process reduces memory by sharing the browser and renderer OS process,
at the cost of slightly reduced crash isolation. This is acceptable for short-lived
serverless workloads where the container is discarded after each invocation.