Gallery › Network › Azure built-in policies
Gateway subnets should not be configured with a network security group
Converted Policy Deny Mode All Version 1.0.0
This policy denies if a gateway subnet is configured with a network security group. Assigning a network security group to a gateway subnet will cause the gateway to stop functioning.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONNetworkSecurityGroupOnGatewaySubnet_Deny.json · 40 lines
{
"properties": {
"displayName": "Gateway subnets should not be configured with a network security group",
"policyType": "BuiltIn",
"mode": "All",
"description": "This policy denies if a gateway subnet is configured with a network security group. Assigning a network security group to a gateway subnet will cause the gateway to stop functioning.",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"version": "1.0.0",
"parameters": {},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/virtualNetworks/subnets"
},
{
"field": "name",
"equals": "GatewaySubnet"
},
{
"field": "Microsoft.Network/virtualNetworks/subnets/networkSecurityGroup.id",
"exists": "true"
}
]
},
"then": {
"effect": "deny"
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/35f9c03a-cc27-418e-9c0c-539ff999d010",
"name": "35f9c03a-cc27-418e-9c0c-539ff999d010"
}Bylaw35f9c03a-cc27-418e-9c0c-539ff999d010.bylaw.ps1 · 25 lines
# Converted from NetworkSecurityGroupOnGatewaySubnet_Deny.json by ConvertTo-Bylaw.
Policy '35f9c03a-cc27-418e-9c0c-539ff999d010' {
Properties @{
DisplayName = 'Gateway subnets should not be configured with a network security group'
Description = 'This policy denies if a gateway subnet is configured with a network security group. Assigning a network security group to a gateway subnet will cause the gateway to stop functioning.'
Version = '1.0.0'
Category = 'Network'
PolicyVersion = '1.0.0'
Mode = 'All'
}
Resource 'Microsoft.Network/virtualNetworks/subnets' {
When {
Field name | Must -Be 'GatewaySubnet'
}
Require 'networkSecurityGroup.id does not exist' {
Field networkSecurityGroup.id | Must -Not -Exist
}
}
Effect Deny
}Source: built-in-policies/policyDefinitions/Network/NetworkSecurityGroupOnGatewaySubnet_Deny.json in Azure/azure-policy, under the MIT licence.
Bylaw