Gallery › Security Center › Azure built-in policies
Subnets should be associated with a Network Security Group
Converted Policy AuditIfNotExists Disabled Mode All Version 3.0.0
Protect your subnet from potential threats by restricting access to it with a Network Security Group (NSG). NSGs contain a list of Access Control List (ACL) rules that allow or deny network traffic to your subnet.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONASC_NetworkSecurityGroupsOnSubnets_Audit.json · 52 lines
{
"properties": {
"displayName": "Subnets should be associated with a Network Security Group",
"policyType": "BuiltIn",
"mode": "All",
"description": "Protect your subnet from potential threats by restricting access to it with a Network Security Group (NSG). NSGs contain a list of Access Control List (ACL) rules that allow or deny network traffic to your subnet.",
"metadata": {
"version": "3.0.0",
"category": "Security Center"
},
"version": "3.0.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Network/virtualNetworks/subnets"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Security/assessments",
"name": "eade5b56-eefd-444f-95c8-23f29e5d93cb",
"existenceCondition": {
"field": "Microsoft.Security/assessments/status.code",
"in": [
"NotApplicable",
"Healthy"
]
}
}
}
},
"versions": [
"3.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/e71308d3-144b-4262-b144-efdc3cc90517",
"name": "e71308d3-144b-4262-b144-efdc3cc90517"
}Bylawe71308d3-144b-4262-b144-efdc3cc90517.bylaw.ps1 · 28 lines
# Converted from ASC_NetworkSecurityGroupsOnSubnets_Audit.json by ConvertTo-Bylaw.
Policy 'e71308d3-144b-4262-b144-efdc3cc90517' {
Properties @{
DisplayName = 'Subnets should be associated with a Network Security Group'
Description = 'Protect your subnet from potential threats by restricting access to it with a Network Security Group (NSG). NSGs contain a list of Access Control List (ACL) rules that allow or deny network traffic to your subnet.'
Version = '3.0.0'
Category = 'Security Center'
PolicyVersion = '3.0.0'
Mode = 'All'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Network/virtualNetworks/subnets'
AuditIfNotExists 'Microsoft.Security/assessments' -Name 'eade5b56-eefd-444f-95c8-23f29e5d93cb' -Effect (Param Effect) {
Require 'status.code is one of 2 values' {
Field status.code | Must -BeIn @('NotApplicable', 'Healthy')
}
}
}Source: built-in-policies/policyDefinitions/Security Center/ASC_NetworkSecurityGroupsOnSubnets_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw