Gallery › Storage › Azure Community Policy
Enforce storage account public firewall blocking access
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
This policy prevents setting storage public firewall as allow all or have any vnet/ip rules.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 72 lines
{
"name": "ed1e9c2b-f8e2-48e8-8bf6-43247c3c8401",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Enforce storage account public firewall blocking access",
"description": "This policy prevents setting storage public firewall as allow all or have any vnet/ip rules.",
"metadata": {
"category": "Storage",
"createdBy": "",
"updatedBy": null,
"updatedOn": null,
"version": "1.0.0"
},
"mode": "Indexed",
"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": [
{
"equals": "Microsoft.Storage/storageAccounts",
"field": "type"
},
{
"anyOf": [
{
"exists": "false",
"field": "Microsoft.Storage/storageAccounts/networkAcls.defaultAction"
},
{
"equals": "Allow",
"field": "Microsoft.Storage/storageAccounts/networkAcls.defaultAction"
},
{
"exists": "false",
"field": "Microsoft.Storage/storageAccounts/networkAcls.virtualNetworkRules"
},
{
"notequals": "0",
"value": "[length(field('Microsoft.Storage/storageAccounts/networkAcls.virtualNetworkRules'))]"
},
{
"exists": "false",
"field": "Microsoft.Storage/storageAccounts/networkAcls.ipRules"
},
{
"notequals": "0",
"value": "[length(field('Microsoft.Storage/storageAccounts/networkAcls.ipRules'))]"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawed1e9c2b-f8e2-48e8-8bf6-43247c3c8401.bylaw.ps1 · 47 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'ed1e9c2b-f8e2-48e8-8bf6-43247c3c8401' {
Properties @{
DisplayName = 'Enforce storage account public firewall blocking access'
Description = 'This policy prevents setting storage public firewall as allow all or have any vnet/ip rules.'
Category = 'Storage'
Version = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Storage/storageAccounts' {
Require 'networkAcls.defaultAction exists' {
Field networkAcls.defaultAction | Must -Exist
}
Require 'networkAcls.defaultAction is not Allow' {
Field networkAcls.defaultAction | Must -Not -Be 'Allow' -IfPresent
}
Require 'networkAcls.virtualNetworkRules exists' {
Field networkAcls.virtualNetworkRules | Must -Exist
}
Require 'networkAcls.virtualNetworkRules is as required' {
Arm '[length(field(''Microsoft.Storage/storageAccounts/networkAcls.virtualNetworkRules''))]' | Must -Be '0'
}
Require 'networkAcls.ipRules exists' {
Field networkAcls.ipRules | Must -Exist
}
Require 'networkAcls.ipRules is as required' {
Arm '[length(field(''Microsoft.Storage/storageAccounts/networkAcls.ipRules''))]' | Must -Be '0'
}
}
Effect (Param Effect)
}Source: policyDefinitions/Storage/enforce-storage-account-public-firewall-blocking-access/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw