Gallery › Security Center › Azure built-in policies
Internet-facing virtual machines should be protected with network security groups
Converted Policy AuditIfNotExists Disabled Mode All Version 3.0.0
Protect your virtual machines from potential threats by restricting access to them with network security groups (NSG). Learn more about controlling traffic with NSGs at https://aka.ms/nsg-doc
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONASC_NetworkSecurityGroupsOnInternetFacingVirtualMachines_Audit.json · 55 lines
{
"properties": {
"displayName": "Internet-facing virtual machines should be protected with network security groups",
"policyType": "BuiltIn",
"mode": "All",
"description": "Protect your virtual machines from potential threats by restricting access to them with network security groups (NSG). Learn more about controlling traffic with NSGs at https://aka.ms/nsg-doc",
"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",
"in": [
"Microsoft.Compute/virtualMachines",
"Microsoft.ClassicCompute/virtualMachines"
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Security/assessments",
"name": "483f12ed-ae23-447e-a2de-a67a10db4353",
"existenceCondition": {
"field": "Microsoft.Security/assessments/status.code",
"in": [
"NotApplicable",
"Healthy"
]
}
}
}
},
"versions": [
"3.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/f6de0be7-9a8a-4b8a-b349-43cf02d22f7c",
"name": "f6de0be7-9a8a-4b8a-b349-43cf02d22f7c"
}Bylawf6de0be7-9a8a-4b8a-b349-43cf02d22f7c.bylaw.ps1 · 33 lines
# Converted from ASC_NetworkSecurityGroupsOnInternetFacingVirtualMachines_Audit.json by ConvertTo-Bylaw.
Policy 'f6de0be7-9a8a-4b8a-b349-43cf02d22f7c' {
Properties @{
DisplayName = 'Internet-facing virtual machines should be protected with network security groups'
Description = 'Protect your virtual machines from potential threats by restricting access to them with network security groups (NSG). Learn more about controlling traffic with NSGs at https://aka.ms/nsg-doc'
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 * {
Require 'type is not one of 2 values' {
Field type | Must -Not -BeIn @('Microsoft.Compute/virtualMachines', 'Microsoft.ClassicCompute/virtualMachines') -IfPresent
}
}
AuditIfNotExists 'Microsoft.Security/assessments' -Name '483f12ed-ae23-447e-a2de-a67a10db4353' -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_NetworkSecurityGroupsOnInternetFacingVirtualMachines_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw