Azion

This module intends to be used with Azion Functions​.

This documentation describes both server-side and client-side integrations.

Prerequisites

Installation

You can download the latest version of the module on this link.

Server-side configuration

The DataDome server-side part is using firewall functions.

Create a firewall function

  1. From the side menu, in the Edge Libraries section, click on Functions.
  2. Click on the + Functions button.
  3. Fill the information in the Main Settings tab:
    1. Name: DataDome Firewall
    2. Execution Environment: Firewall
    3. Status: Active
  4. In the Code tab, paste the content of the firewall.js script.
  5. Save your changes.

Create a firewall

  1. From the side menu, in the Secure section, click on Firewalls.

  2. Click on the + Firewall button.

  3. Fill the informations in the Main Settings tab:

    1. Name: DataDome
    2. Add the following Modules:
      1. DDoS Protection Unmetered
      2. Function
    3. Status: Active
  4. Click on Create.

  5. In the Function Instances tab, click on the + Function button and fill the information:

    1. Name: DataDome
    2. Function: Select the DataDome Firewall function you created.
    3. Add your server-side settings to the Arguments section.
  6. In the Rules Engine tab, click on the + Rule button and fill the information:

    1. Name: DataDome Rule
    2. Criteria: Request Uri starts with /
    3. Behaviors: Run Function and select the DataDome function you just created.

Your service is now protected!

Client-side configuration

The DataDome client-side part is injecting the JS Tag on HTML responses by using application functions.

Limitation on the size of the response body

Azion has no streaming HTML rewriter, so the module buffers the entire response body in memory before injecting the JS Tag.

To stay within the CPU and memory limits of Azion Functions, HTML responses larger than maximumResponseBodySize (2 MB by default) are passed through unmodified, without the JS Tag.

You can adjust this threshold in the Client-side settings.

Create an application function

  1. From the side menu, in the Edge Libraries section, click on Functions.
  2. Click on the + Functions button.
  3. Fill the information in the Main Settings tab:
    1. Name: DataDome JS Tag Injection
    2. Execution Environment: Application
    3. Status: Active
  4. In the Code tab, paste the content of the js-tag-injection.js script.
  5. Save your changes.

Update your application

Access the settings of the application you created.

  1. In the Main Settings tab, enable the Functions part in the Modules section.
  2. In the Functions Instances tab, click on the + Functions button and fill the information:
    1. Name: DataDome JS Tag
    2. Function: Select the DataDome JS Tag Injection function you created.
    3. Provide your client-side settings in the Arguments section.
  3. In the Rules Engine tab, click on the + Rule button and fill the information:
    1. Name: DataDome Rule
    2. Phase: Request Phase
    3. Criteria: Request Uri starts with /
    4. Behaviors: Run Function and select the DataDome JS Tag function you just created.

The JS Tag is now injected on the HTML response sent by your origin.

Settings

Server-side settings

Environment variable / argumentDescriptionRequiredDefault valueExample
serverSideKeyYour DataDome server-side key, found in your dashboard.Yes--
endpointURL of the Protection API.Nohttps://api-azion.datadome.co/validate-request/-
timeoutRequest timeout to Protection API, in milliseconds.No300350
urlPatternExclusionRegular expression to exclude URLs from being sent to the Protection API.No-/admin/
urlPatternInclusionRegular expression to only send certain URLs to the Protection API.No-/login
staticAssetExclusionRegular expression (case-insensitive) to exclude static assets from being sent to the Protection API.NoList of excluded static assets below-
encodedCharInclusionRegular expression (case-insensitive) forcing the analysis of static assets with a path that contains encoded characters. Set an empty value to disable.No%23|%25|%2f|%3b|%3f-
removeMatrixParamsRemove matrix parameters (;param=value) from the path before matching the URL patterns.Notruefalse
ipExclusionList of IPs or CIDR for traffic that must not be sent to the Protection API.No-["192.168.0.1", "192.168.0.2", "192.168.0.0/24"]
logEnrichedHeadersEnable logs for Enriched headers.Nofalsetrue
enableGraphQLSupportExtract GraphQL operation name and type on requests to a GraphQL endpoint to improve protection.Nofalsetrue
graphQLEndpointGraphQL endpoint on which the operation name and type should be extracted.
You can specify multiple endpoints separated with commas.
Nographql-
enableMCPSupportBoolean to enable Model Context Protocol support.Nofalsetrue
mcpEndpointMCP endpoint on which the information should be extracted.
You can specify multiple endpoints separated with commas.
Nomcp-
maximumBodySizeMaximum size of the request body read for GraphQL and MCP extraction, in bytes.No25600 (25 KB)-
enableDebuggingLog detailed information about the DataDome process.Nofalsetrue
customFieldString1Static value or callback function to send a custom string. Refer to Add custom field section.No--
customFieldString2Static value or callback function to send a custom string. Refer to Add custom field section.No--
customFieldString3Static value or callback function to send a custom string. Refer to Add custom field section.No--
customFieldInteger1Static value or callback function to send a custom integer. Refer to Add custom field section.No--
customFieldInteger2Static value or callback function to send a custom integer. Refer to Add custom field section.No--
customFieldFloat1Static value or callback function to send a custom float. Refer to Add custom field section.No--
userIDStatic value or callback function to send a custom value representing a user ID. Refer to Add custom field section.No--
productIDStatic value or callback function to send a custom value representing a product ID. Refer to Add custom field section.No--
/\.(avi|avif|bmp|css|eot|flac|flv|gif|gz|ico|jpeg|jpg|js|json|less|map|mka|mkv|mov|mp3|mp4|mpeg|mpg|ogg|ogm|opus|otf|png|svg|svgz|swf|ttf|wav|webm|webp|woff|woff2|xml|zip)$/i

Client-side settings

Environment variable / argumentDescriptionRequiredDefault valueExample
clientSideKeyYour DataDome client-side key, found in your dashboard.Yes--
jsURLURL of the DataDome JS Tag that can be changed to include the tag as a first party.Nohttps://js.datadome.co/tags.jshttps://ddfoo.com/tags.js
jsTagOptionsJSON object describing DataDome JS Tag options.No{}{ "ajaxListenerPath": "example.com" }
originURLScheme and host of your origin, used to fetch the HTML response. Set it to avoid the function fetching itself through your Azion domain (the loop is stopped with a 508 response).No-https://origin.example.com
maximumResponseBodySizeMaximum size of the response body to inject the JS Tag, in bytes. Larger responses are returned without the JS Tag.No2097152 (2 MB)-

Did this page help you?