Skip to content

110. [Ingress] How to configure statically (via config files)

Konstantin Lepeshenkov edited this page May 15, 2024 · 5 revisions

1. Add a ThrottlingTrollIngress section with rules and limits

to your appsettings.json (or host.json, if it is Azure Functions):

{
  ...

  "ThrottlingTrollIngress": {

    "Rules": [
        ... here go rate limiting rules and limits...
    ],

    "WhiteList": [
        ... here go whitelisted URIs...
    ]
  }

  ...
}

NOTE: in Azure Functions you will also need to explicitly load configuration values from host.json file with a code like this:

builder.ConfigureAppConfiguration(configBuilder => {
    configBuilder.AddJsonFile("host.json", optional: false, reloadOnChange: true);
});

The ThrottlingTrollIngress config section is represented by ThrottlingTrollConfig class, you can use all properties of that class in your configuration.

2. At your service's startup call .UseThrottlingTroll():

// Either like this:
app.UseThrottlingTroll();

// Or like this:
app.UseThrottlingTroll(options => 
{
  // Configure other parameters here
});