Gallery › Network › Azure Community Policy
No User Defined Route Table
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
Forbid virtual networks to use user defined route table
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 63 lines
{
"name": "1bcf6131-5f68-45ab-8ae9-d41bbc588674",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "No User Defined Route Table",
"description": "Forbid virtual networks to use user defined route table",
"metadata": {
"version": "1.0.0",
"category": "Network"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"anyOf": [
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/virtualNetworks"
},
{
"not": {
"field": "Microsoft.Network/virtualNetworks/subnets[*].routeTable.id",
"exists": false
}
}
]
},
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/virtualNetworks/subnets"
},
{
"field": "Microsoft.Network/virtualNetworks/subnets/routeTable.id",
"exists": true
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw1bcf6131-5f68-45ab-8ae9-d41bbc588674.bylaw.ps1 · 39 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '1bcf6131-5f68-45ab-8ae9-d41bbc588674' {
Properties @{
DisplayName = 'No User Defined Route Table'
Description = 'Forbid virtual networks to use user defined route table'
Version = '1.0.0'
Category = 'Network'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource * {
Require 'type, subnets and routeTable.id are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Network/virtualNetworks' -IfPresent
Each 'Microsoft.Network/virtualNetworks/subnets[*]' {
Field routeTable.id | Must -Not -Exist
}
}
}
Require 'type and routeTable.id are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.Network/virtualNetworks/subnets' -IfPresent
Field 'Microsoft.Network/virtualNetworks/subnets/routeTable.id' | Must -Not -Exist
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/no-user-defined-route-table/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw