Gallery › Service Bus › Azure Community Policy
Service Bus Namespace - Firewall Settings AUDIT
Converted Policy Audit Disabled Mode All Version 1.0.0
This Azure Policy creates an audit event when the 'Public network access' setting is not set to 'Disabled' or 'Selected networks', and when the PaaS Firewall does not contain the correct IP address ranges.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 89 lines
{
"name": "b5f9394d-6982-494f-ac63-bc57bc7eef40",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Service Bus Namespace - Firewall Settings AUDIT",
"description": "This Azure Policy creates an audit event when the 'Public network access' setting is not set to 'Disabled' or 'Selected networks', and when the PaaS Firewall does not contain the correct IP address ranges.",
"metadata": {
"version": "1.0.0",
"category": "Service Bus"
},
"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 a Service Bus Namespace"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"anyOf": [
{
"allOf": [
{
"field": "type",
"equals": "Microsoft.ServiceBus/namespaces/networkRuleSets"
},
{
"anyOf": [
{
"allOf": [
{
"field": "Microsoft.ServiceBus/namespaces/networkRuleSets/publicNetworkAccess",
"equals": "Enabled"
},
{
"field": "Microsoft.ServiceBus/namespaces/networkRuleSets/defaultAction",
"equals": "Allow"
}
]
},
{
"allOf": [
{
"field": "Microsoft.ServiceBus/namespaces/networkRuleSets/defaultAction",
"equals": "Deny"
},
{
"count": {
"field": "Microsoft.ServiceBus/namespaces/networkRuleSets/ipRules[*]",
"where": {
"allOf": [
{
"value": "[current('Microsoft.ServiceBus/namespaces/networkRuleSets/ipRules[*].ipMask')]",
"notIn": "[parameters('allowedAddressRanges')]"
}
]
}
},
"greater": 0
}
]
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawb5f9394d-6982-494f-ac63-bc57bc7eef40.bylaw.ps1 · 46 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'b5f9394d-6982-494f-ac63-bc57bc7eef40' {
Properties @{
DisplayName = 'Service Bus Namespace - Firewall Settings AUDIT'
Description = 'This Azure Policy creates an audit event when the ''Public network access'' setting is not set to ''Disabled'' or ''Selected networks'', and when the PaaS Firewall does not contain the correct IP address ranges.'
Version = '1.0.0'
Category = 'Service Bus'
Mode = 'All'
}
Parameter AllowedAddressRanges @{
Type = 'Array'
DisplayName = 'Allowed Address Ranges'
Description = 'The list of IP Addresses or IP Address Ranges that are allowed for a Service Bus Namespace'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Audit or Disabled the execution of the Policy'
}
Resource * {
Require 'type, publicNetworkAccess, defaultAction and 1 more are as required' {
AnyOf {
Field type | Must -Not -Be 'Microsoft.ServiceBus/namespaces/networkRuleSets' -IfPresent
AllOf {
AnyOf {
Field 'Microsoft.ServiceBus/namespaces/networkRuleSets/publicNetworkAccess' | Must -Not -Be 'Enabled' -IfPresent
Field 'Microsoft.ServiceBus/namespaces/networkRuleSets/defaultAction' | Must -Not -Be 'Allow' -IfPresent
}
AnyOf {
Field 'Microsoft.ServiceBus/namespaces/networkRuleSets/defaultAction' | Must -Not -Be 'Deny' -IfPresent
Count 'Microsoft.ServiceBus/namespaces/networkRuleSets/ipRules[*]' -Where {
Arm '[current(''Microsoft.ServiceBus/namespaces/networkRuleSets/ipRules[*].ipMask'')]' | Must -Not -BeIn (Param AllowedAddressRanges)
} | Must -Be 0
}
}
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Service Bus/service-bus-namespace-firewall-settings-audit/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw