Gallery › Network › Azure built-in policies
[Preview]: All Internet traffic should be routed via your deployed Azure Firewall
Converted Policy AuditIfNotExists Disabled Mode All Version 3.0.0-preview Preview
Azure Security Center has identified that some of your subnets aren't protected with a next generation firewall. Protect your subnets from potential threats by restricting access to them with Azure Firewall or a supported next generation firewall
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONASC_All_Internet_traffic_should_be_routed_via_Azure_Firewall.json · 97 lines
{
"properties": {
"displayName": "[Preview]: All Internet traffic should be routed via your deployed Azure Firewall",
"policyType": "BuiltIn",
"mode": "All",
"description": "Azure Security Center has identified that some of your subnets aren't protected with a next generation firewall. Protect your subnets from potential threats by restricting access to them with Azure Firewall or a supported next generation firewall",
"metadata": {
"version": "3.0.0-preview",
"category": "Network",
"preview": true
},
"version": "3.0.0-preview",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable All Internet traffic should be routed via your deployed Azure Firewall"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/virtualNetworks"
},
{
"count": {
"field": "Microsoft.Network/virtualNetworks/subnets[*]",
"where": {
"allOf": [
{
"count": {
"field": "Microsoft.Network/virtualNetworks/subnets[*].ipConfigurations[*]",
"where": {
"value": "[empty(field('Microsoft.Network/virtualNetworks/subnets[*].ipConfigurations[*].id'))]",
"equals": false
}
},
"greaterOrEquals": 2
},
{
"field": "Microsoft.Network/virtualNetworks/subnets[*].routeTable",
"exists": false
},
{
"not": {
"anyOf": [
{
"field": "Microsoft.Network/virtualNetworks/subnets[*].name",
"equals": "AzureBastionSubnet"
},
{
"field": "Microsoft.Network/virtualNetworks/subnets[*].name",
"equals": "GatewaySubnet"
}
]
}
}
]
}
},
"greater": 0
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Network/azureFirewalls",
"existenceCondition": {
"count": {
"field": "Microsoft.Network/azureFirewalls/ipConfigurations[*]",
"where": {
"field": "Microsoft.Network/azureFirewalls/ipConfigurations[*].subnet.id",
"like": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/*/providers/Microsoft.Network/virtualNetworks/', first(split(field('fullName'), '/')), '/subnets/AzureFirewallSubnet')]"
}
},
"equals": 1
}
}
}
},
"versions": [
"3.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/fc5e4038-4584-4632-8c85-c0448d374b2c",
"name": "fc5e4038-4584-4632-8c85-c0448d374b2c"
}Bylawfc5e4038-4584-4632-8c85-c0448d374b2c.bylaw.ps1 · 47 lines
# Converted from ASC_All_Internet_traffic_should_be_routed_via_Azure_Firewall.json by ConvertTo-Bylaw.
Policy 'fc5e4038-4584-4632-8c85-c0448d374b2c' {
Properties @{
DisplayName = '[Preview]: All Internet traffic should be routed via your deployed Azure Firewall'
Description = 'Azure Security Center has identified that some of your subnets aren''t protected with a next generation firewall. Protect your subnets from potential threats by restricting access to them with Azure Firewall or a supported next generation firewall'
Version = '3.0.0-preview'
Category = 'Network'
Preview = $true
PolicyVersion = '3.0.0-preview'
Mode = 'All'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable All Internet traffic should be routed via your deployed Azure Firewall'
}
Resource 'Microsoft.Network/virtualNetworks' {
Require 'subnets, ipConfigurations, routeTable and 2 more are as required' {
Each 'subnets[*]' {
AnyOf {
Count 'ipConfigurations[*]' -Where {
Arm '[empty(field(''Microsoft.Network/virtualNetworks/subnets[*].ipConfigurations[*].id''))]' | Must -Be $false
} | Must -BeLessThan 2
Field routeTable | Must -Exist
AnyOf {
Field name | Must -Be 'AzureBastionSubnet' -Strict
Field name | Must -Be 'GatewaySubnet' -Strict
}
}
}
}
}
AuditIfNotExists 'Microsoft.Network/azureFirewalls' -Effect (Param Effect) {
Require 'ipConfigurations, subnet.id and fullName are as required' {
Count 'ipConfigurations[*]' -Where {
Field subnet.id | Must -BeLike (Arm '[concat(''/subscriptions/'', subscription().subscriptionId, ''/resourceGroups/*/providers/Microsoft.Network/virtualNetworks/'', first(split(field(''fullName''), ''/'')), ''/subnets/AzureFirewallSubnet'')]')
} | Must -Be 1
}
}
}Source: built-in-policies/policyDefinitions/Network/ASC_All_Internet_traffic_should_be_routed_via_Azure_Firewall.json in Azure/azure-policy, under the MIT licence.
Bylaw