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.
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
SecurityPolicyPropertiesParameters
SecurityPolicyWebApplicationFirewallAssociation
SecurityPolicyWebApplicationFirewallParameters
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.
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
SecurityPolicyPropertiesParameters
SecurityPolicyWebApplicationFirewallAssociation
SecurityPolicyWebApplicationFirewallParameters
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
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 = ["*"]
}
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
SecurityPolicyPropertiesParameters
SecurityPolicyWebApplicationFirewallAssociation
SecurityPolicyWebApplicationFirewallParameters