Microsoft.Cdn profiles/securityPolicies 2024-02-01

Bicep resource definition

The profiles/securityPolicies resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Usage Examples

Bicep Samples

A basic example of deploying Front Door (standard/premium) Security Policy.

param resourceName string = 'acctest0001'
param location string = 'westeurope'

resource profile 'Microsoft.Cdn/profiles@2021-06-01' = {
  name: resourceName
  location: 'global'
  sku: {
    name: 'Premium_AzureFrontDoor'
  }
  properties: {
    originResponseTimeoutSeconds: 120
  }
}

resource securityPolicy 'Microsoft.Cdn/profiles/securityPolicies@2021-06-01' = {
  name: resourceName
  parent: profile
  properties: {
    parameters: {
      associations: [
        {
          domains: [
            {
              id: customDomain.id
            }
          ]
          patternsToMatch: [
            '/*'
          ]
        }
      ]
      type: 'WebApplicationFirewall'
      wafPolicy: {
        id: frontDoorWebApplicationFirewallPolicy.id
      }
    }
  }
}

resource frontDoorWebApplicationFirewallPolicy 'Microsoft.Network/FrontDoorWebApplicationFirewallPolicies@2020-11-01' = {
  name: resourceName
  location: 'global'
  sku: {
    name: 'Premium_AzureFrontDoor'
  }
  properties: {
    customRules: {
      rules: [
        {
          action: 'Block'
          enabledState: 'Enabled'
          matchConditions: [
            {
              matchValue: [
                '192.168.1.0/24'
                '10.0.0.0/24'
              ]
              matchVariable: 'RemoteAddr'
              negateCondition: false
              operator: 'IPMatch'
            }
          ]
          name: 'Rule1'
          priority: 1
          rateLimitDurationInMinutes: 1
          rateLimitThreshold: 10
          ruleType: 'MatchRule'
        }
      ]
    }
    managedRules: {
      managedRuleSets: [
        {
          ruleGroupOverrides: [
            {
              ruleGroupName: 'PHP'
              rules: [
                {
                  action: 'Block'
                  enabledState: 'Disabled'
                  ruleId: '933111'
                }
              ]
            }
          ]
          ruleSetAction: 'Block'
          ruleSetType: 'DefaultRuleSet'
          ruleSetVersion: 'preview-0.1'
        }
        {
          ruleSetAction: 'Block'
          ruleSetType: 'BotProtection'
          ruleSetVersion: 'preview-0.1'
        }
      ]
    }
    policySettings: {
      customBlockResponseBody: 'PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=='
      customBlockResponseStatusCode: 403
      enabledState: 'Enabled'
      mode: 'Prevention'
      redirectUrl: 'https://www.fabrikam.com'
    }
  }
}

resource dnsZone 'Microsoft.Network/dnsZones@2018-05-01' = {
  name: '${resourceName}.com'
  location: 'global'
}

resource customDomain 'Microsoft.Cdn/profiles/customDomains@2021-06-01' = {
  name: resourceName
  parent: profile
  properties: {
    azureDnsZone: {
      id: dnsZone.id
    }
    hostName: 'fabrikam.${resourceName}.com'
    tlsSettings: {
      certificateType: 'ManagedCertificate'
      minimumTlsVersion: 'TLS12'
    }
  }
}

Azure Quickstart Samples

The following Azure Quickstart templates contain Bicep samples for deploying this resource type.

Bicep File Description
Front Door Premium with blob origin and Private Link This template creates a Front Door Premium and an Azure Storage blob container, and uses a private endpoint for Front Door to send traffic to the storage account.
Front Door Premium with WAF and Microsoft-managed rule sets This template creates a Front Door Premium including a web application firewall with the Microsoft-managed default and bot protection rule sets.
Front Door Standard/Premium with geo-filtering This template creates a Front Door Standard/Premium including a web application firewall with a geo-filtering rule.
Front Door Standard/Premium with rate limit This template creates a Front Door Standard/Premium including a web application firewall with a rate limit rule.
Front Door Standard/Premium with WAF and custom rule This template creates a Front Door Standard/Premium including a web application firewall with a custom rule.
Front Door with blob origins for blobs upload This template creates a Front Door with origins, routes and ruleSets, and an Azure Storage accounts with blob containers. Front Door sends traffic to the storage accounts when uploading files.
FrontDoor CDN with WAF, Domains and Logs to EventHub This template creates a new Azure FrontDoor cdn profile. Create WAF with custom and managed rules, cdn routes, origin and groups with their association with WAF and routes, configures custom domains, create event hub and diagnostic settings for sending CDN access logs using event hub.
Function App secured by Azure Frontdoor This template allows you to deploy an azure premium function protected and published by Azure Frontdoor premium. The conenction between Azure Frontdoor and Azure Functions is protected by Azure Private Link.

Resource format

To create a Microsoft.Cdn/profiles/securityPolicies resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.Cdn/profiles/securityPolicies@2024-02-01' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    parameters: {
      type: 'string'
      // For remaining properties, see SecurityPolicyPropertiesParameters objects
    }
  }
}

SecurityPolicyPropertiesParameters objects

Set the type property to specify the type of object.

For WebApplicationFirewall, use:

{
  associations: [
    {
      domains: [
        {
          id: 'string'
        }
      ]
      patternsToMatch: [
        'string'
      ]
    }
  ]
  type: 'WebApplicationFirewall'
  wafPolicy: {
    id: 'string'
  }
}

Property Values

Microsoft.Cdn/profiles/securityPolicies

Name Description Value
name The resource name string (required)
parent In Bicep, you can specify the parent resource for a child resource. You only need to add this property when the child resource is declared outside of the parent resource.

For more information, see Child resource outside parent resource.
Symbolic name for resource of type: profiles
properties The json object that contains properties required to create a security policy SecurityPolicyProperties

ActivatedResourceReference

Name Description Value
id Resource ID. string

ResourceReference

Name Description Value
id Resource ID. string

SecurityPolicyProperties

Name Description Value
parameters object which contains security policy parameters SecurityPolicyPropertiesParameters

SecurityPolicyPropertiesParameters

Name Description Value
type Set to 'WebApplicationFirewall' for type SecurityPolicyWebApplicationFirewallParameters. 'WebApplicationFirewall' (required)

SecurityPolicyWebApplicationFirewallAssociation

Name Description Value
domains List of domains. ActivatedResourceReference[]
patternsToMatch List of paths string[]

SecurityPolicyWebApplicationFirewallParameters

Name Description Value
associations Waf associations SecurityPolicyWebApplicationFirewallAssociation[]
type The type of the Security policy to create. 'WebApplicationFirewall' (required)
wafPolicy Resource ID. ResourceReference

ARM template resource definition

The profiles/securityPolicies resource type can be deployed with operations that target:

Usage Examples

Azure Quickstart Templates

The following Azure Quickstart templates deploy this resource type.

Template Description
Front Door Premium with blob origin and Private Link

Deploy to Azure
This template creates a Front Door Premium and an Azure Storage blob container, and uses a private endpoint for Front Door to send traffic to the storage account.
Front Door Premium with WAF and Microsoft-managed rule sets

Deploy to Azure
This template creates a Front Door Premium including a web application firewall with the Microsoft-managed default and bot protection rule sets.
Front Door Standard/Premium with geo-filtering

Deploy to Azure
This template creates a Front Door Standard/Premium including a web application firewall with a geo-filtering rule.
Front Door Standard/Premium with rate limit

Deploy to Azure
This template creates a Front Door Standard/Premium including a web application firewall with a rate limit rule.
Front Door Standard/Premium with WAF and custom rule

Deploy to Azure
This template creates a Front Door Standard/Premium including a web application firewall with a custom rule.
Front Door with blob origins for blobs upload

Deploy to Azure
This template creates a Front Door with origins, routes and ruleSets, and an Azure Storage accounts with blob containers. Front Door sends traffic to the storage accounts when uploading files.
FrontDoor CDN with WAF, Domains and Logs to EventHub

Deploy to Azure
This template creates a new Azure FrontDoor cdn profile. Create WAF with custom and managed rules, cdn routes, origin and groups with their association with WAF and routes, configures custom domains, create event hub and diagnostic settings for sending CDN access logs using event hub.
Function App secured by Azure Frontdoor

Deploy to Azure
This template allows you to deploy an azure premium function protected and published by Azure Frontdoor premium. The conenction between Azure Frontdoor and Azure Functions is protected by Azure Private Link.

Resource format

To create a Microsoft.Cdn/profiles/securityPolicies resource, add the following JSON to your template.

{
  "type": "Microsoft.Cdn/profiles/securityPolicies",
  "apiVersion": "2024-02-01",
  "name": "string",
  "properties": {
    "parameters": {
      "type": "string"
      // For remaining properties, see SecurityPolicyPropertiesParameters objects
    }
  }
}

SecurityPolicyPropertiesParameters objects

Set the type property to specify the type of object.

For WebApplicationFirewall, use:

{
  "associations": [
    {
      "domains": [
        {
          "id": "string"
        }
      ],
      "patternsToMatch": [ "string" ]
    }
  ],
  "type": "WebApplicationFirewall",
  "wafPolicy": {
    "id": "string"
  }
}

Property Values

Microsoft.Cdn/profiles/securityPolicies

Name Description Value
apiVersion The api version '2024-02-01'
name The resource name string (required)
properties The json object that contains properties required to create a security policy SecurityPolicyProperties
type The resource type 'Microsoft.Cdn/profiles/securityPolicies'

ActivatedResourceReference

Name Description Value
id Resource ID. string

ResourceReference

Name Description Value
id Resource ID. string

SecurityPolicyProperties

Name Description Value
parameters object which contains security policy parameters SecurityPolicyPropertiesParameters

SecurityPolicyPropertiesParameters

Name Description Value
type Set to 'WebApplicationFirewall' for type SecurityPolicyWebApplicationFirewallParameters. 'WebApplicationFirewall' (required)

SecurityPolicyWebApplicationFirewallAssociation

Name Description Value
domains List of domains. ActivatedResourceReference[]
patternsToMatch List of paths string[]

SecurityPolicyWebApplicationFirewallParameters

Name Description Value
associations Waf associations SecurityPolicyWebApplicationFirewallAssociation[]
type The type of the Security policy to create. 'WebApplicationFirewall' (required)
wafPolicy Resource ID. ResourceReference

Terraform (AzAPI provider) resource definition

The profiles/securityPolicies resource type can be deployed with operations that target:

  • Resource groups For a list of changed properties in each API version, see change log.

Usage Examples

Terraform Samples

A basic example of deploying Front Door (standard/premium) Security Policy.

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "dnsZone" {
  type                      = "Microsoft.Network/dnsZones@2018-05-01"
  parent_id                 = azapi_resource.resourceGroup.id
  name                      = "${var.resource_name}.com"
  location                  = "global"
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "profile" {
  type      = "Microsoft.Cdn/profiles@2021-06-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = "global"
  body = {
    properties = {
      originResponseTimeoutSeconds = 120
    }
    sku = {
      name = "Premium_AzureFrontDoor"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "FrontDoorWebApplicationFirewallPolicy" {
  type      = "Microsoft.Network/FrontDoorWebApplicationFirewallPolicies@2020-11-01"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = "global"
  body = {
    properties = {
      customRules = {
        rules = [
          {
            action       = "Block"
            enabledState = "Enabled"
            matchConditions = [
              {
                matchValue = [
                  "192.168.1.0/24",
                  "10.0.0.0/24",
                ]
                matchVariable   = "RemoteAddr"
                negateCondition = false
                operator        = "IPMatch"
              },
            ]
            name                       = "Rule1"
            priority                   = 1
            rateLimitDurationInMinutes = 1
            rateLimitThreshold         = 10
            ruleType                   = "MatchRule"
          },
        ]
      }
      managedRules = {
        managedRuleSets = [
          {
            ruleGroupOverrides = [
              {
                ruleGroupName = "PHP"
                rules = [
                  {
                    action       = "Block"
                    enabledState = "Disabled"
                    ruleId       = "933111"
                  },
                ]
              },
            ]
            ruleSetAction  = "Block"
            ruleSetType    = "DefaultRuleSet"
            ruleSetVersion = "preview-0.1"
          },
          {
            ruleSetAction  = "Block"
            ruleSetType    = "BotProtection"
            ruleSetVersion = "preview-0.1"
          },
        ]
      }
      policySettings = {
        customBlockResponseBody       = "PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=="
        customBlockResponseStatusCode = 403
        enabledState                  = "Enabled"
        mode                          = "Prevention"
        redirectUrl                   = "https://www.fabrikam.com"
      }
    }
    sku = {
      name = "Premium_AzureFrontDoor"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "customDomain" {
  type      = "Microsoft.Cdn/profiles/customDomains@2021-06-01"
  parent_id = azapi_resource.profile.id
  name      = var.resource_name
  body = {
    properties = {
      azureDnsZone = {
        id = azapi_resource.dnsZone.id
      }
      hostName = "fabrikam.${var.resource_name}.com"
      tlsSettings = {
        certificateType   = "ManagedCertificate"
        minimumTlsVersion = "TLS12"
      }
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "securityPolicy" {
  type      = "Microsoft.Cdn/profiles/securityPolicies@2021-06-01"
  parent_id = azapi_resource.profile.id
  name      = var.resource_name
  body = {
    properties = {
      parameters = {
        associations = [
          {
            domains = [
              {
                id = azapi_resource.customDomain.id
              },
            ]
            patternsToMatch = [
              "/*",
            ]
          },
        ]
        type = "WebApplicationFirewall"
        wafPolicy = {
          id = azapi_resource.FrontDoorWebApplicationFirewallPolicy.id
        }
      }
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

Resource format

To create a Microsoft.Cdn/profiles/securityPolicies resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Cdn/profiles/securityPolicies@2024-02-01"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      parameters = {
        type = "string"
        // For remaining properties, see SecurityPolicyPropertiesParameters objects
      }
    }
  }
}

SecurityPolicyPropertiesParameters objects

Set the type property to specify the type of object.

For WebApplicationFirewall, use:

{
  associations = [
    {
      domains = [
        {
          id = "string"
        }
      ]
      patternsToMatch = [
        "string"
      ]
    }
  ]
  type = "WebApplicationFirewall"
  wafPolicy = {
    id = "string"
  }
}

Property Values

Microsoft.Cdn/profiles/securityPolicies

Name Description Value
name The resource name string (required)
parent_id The ID of the resource that is the parent for this resource. ID for resource of type: profiles
properties The json object that contains properties required to create a security policy SecurityPolicyProperties
type The resource type "Microsoft.Cdn/profiles/securityPolicies@2024-02-01"

ActivatedResourceReference

Name Description Value
id Resource ID. string

ResourceReference

Name Description Value
id Resource ID. string

SecurityPolicyProperties

Name Description Value
parameters object which contains security policy parameters SecurityPolicyPropertiesParameters

SecurityPolicyPropertiesParameters

Name Description Value
type Set to 'WebApplicationFirewall' for type SecurityPolicyWebApplicationFirewallParameters. 'WebApplicationFirewall' (required)

SecurityPolicyWebApplicationFirewallAssociation

Name Description Value
domains List of domains. ActivatedResourceReference[]
patternsToMatch List of paths string[]

SecurityPolicyWebApplicationFirewallParameters

Name Description Value
associations Waf associations SecurityPolicyWebApplicationFirewallAssociation[]
type The type of the Security policy to create. 'WebApplicationFirewall' (required)
wafPolicy Resource ID. ResourceReference