Gallery › Storage › Azure Community Policy
Storage Account - Firewall Settings AUDIT
Converted Policy Audit Disabled Mode All Version 1.0.0
This Azure Policy creates an audit event when the 'Allow access from' setting is not set to 'Selected networks' and when the Firewall does contain any IP addresses outside of the approved ones.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 69 lines
{
"name": "24fb038c-d2e1-4ef3-ba98-6f2619154092",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Storage Account - Firewall Settings AUDIT",
"description": "This Azure Policy creates an audit event when the 'Allow access from' setting is not set to 'Selected networks' and when the Firewall does contain any IP addresses outside of the approved ones.",
"metadata": {
"version": "1.0.0",
"category": "Storage"
},
"mode": "All",
"parameters": {
"allowedAddressRanges": {
"type": "Array",
"metadata": {
"displayName": "Allowed Address Ranges",
"description": "The list of IP Addresses or IP Address Ranges that are allowed for the Firewall Setting on the Storage Account"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Storage/storageAccounts"
},
{
"anyOf": [
{
"allOf": [
{
"field": "Microsoft.Storage/storageAccounts/networkAcls.ipRules[*].value",
"notEquals": ""
},
{
"not": {
"field": "Microsoft.Storage/storageAccounts/networkAcls.ipRules[*].value",
"in": "[parameters('allowedAddressRanges')]"
}
}
]
},
{
"field": "Microsoft.Storage/storageAccounts/networkAcls.defaultAction",
"equals": "Allow"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw24fb038c-d2e1-4ef3-ba98-6f2619154092.bylaw.ps1 · 46 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '24fb038c-d2e1-4ef3-ba98-6f2619154092' {
Properties @{
DisplayName = 'Storage Account - Firewall Settings AUDIT'
Description = 'This Azure Policy creates an audit event when the ''Allow access from'' setting is not set to ''Selected networks'' and when the Firewall does contain any IP addresses outside of the approved ones.'
Version = '1.0.0'
Category = 'Storage'
Mode = 'All'
}
Parameter AllowedAddressRanges @{
Type = 'Array'
DisplayName = 'Allowed Address Ranges'
Description = 'The list of IP Addresses or IP Address Ranges that are allowed for the Firewall Setting on the Storage Account'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Storage/storageAccounts' {
Require 'networkAcls.ipRules and value are as required' {
AnyOf {
Count 'networkAcls.ipRules[*]' -Where {
Field value | Must -Be ''
} | Must -Not -Be 0
AllOf {
Field networkAcls.ipRules | Must -Exist
Each 'networkAcls.ipRules[*]' {
Field value | Must -BeIn (Param AllowedAddressRanges) -Strict
}
}
}
}
Require 'networkAcls.defaultAction is not Allow' {
Field networkAcls.defaultAction | Must -Not -Be 'Allow' -IfPresent
}
}
Effect (Param Effect)
}Source: policyDefinitions/Storage/storage-account-firewall-settings-audit/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw