Gallery › Network › Azure Community Policy
Network Security Groups - Allow inbound rules with any as source
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy restricts the creation of inbound security rules with the source "Any" with allow access action.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 53 lines
{
"name": "35f46b9d-8c22-48bc-8a92-60f960d039de",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Network Security Groups - Allow inbound rules with any as source",
"description": "This policy restricts the creation of inbound security rules with the source \"Any\" with allow access action.",
"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": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/networkSecurityGroups/securityRules"
},
{
"field": "Microsoft.Network/networkSecurityGroups/securityRules/sourceAddressPrefix",
"equals": "*"
},
{
"field": "Microsoft.Network/networkSecurityGroups/securityRules/access",
"equals": "Allow"
},
{
"field": "Microsoft.Network/networkSecurityGroups/securityRules/direction",
"equals": "Inbound"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw35f46b9d-8c22-48bc-8a92-60f960d039de.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '35f46b9d-8c22-48bc-8a92-60f960d039de' {
Properties @{
DisplayName = 'Network Security Groups - Allow inbound rules with any as source'
Description = 'This policy restricts the creation of inbound security rules with the source "Any" with allow access action.'
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 'Microsoft.Network/networkSecurityGroups/securityRules' {
When {
Field sourceAddressPrefix | Must -Be '*'
Field access | Must -Be 'Allow'
}
Require 'direction is not Inbound' {
Field direction | Must -Not -Be 'Inbound' -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/network-security-groups-allow-inbound-rules-with-any-as-source/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw