Bylaw

Gallery › Service Bus › Azure Community Policy

Service Bus Namespace - Trusted Microsoft Services AUDIT

Converted Policy Audit Disabled Mode All Version 1.0.0

This Azure Policy creates an audit event when the 'Allow trusted Microsoft services to bypass this firewall?' setting is set to 'Yes'.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONazurepolicy.json · 44 lines
{
  "name": "54d9feff-c301-4c4a-b655-e9ccc53b2c9c",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Service Bus Namespace - Trusted Microsoft Services AUDIT",
    "description": "This Azure Policy creates an audit event when the 'Allow trusted Microsoft services to bypass this firewall?' setting is set to 'Yes'.",
    "metadata": {
      "version": "1.0.0",
      "category": "Service Bus"
    },
    "mode": "All",
    "parameters": {
      "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.ServiceBus/namespaces/networkRuleSets"
          },
          {
            "field": "Microsoft.ServiceBus/namespaces/networkRuleSets/trustedServiceAccessEnabled",
            "equals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw54d9feff-c301-4c4a-b655-e9ccc53b2c9c.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '54d9feff-c301-4c4a-b655-e9ccc53b2c9c' {

    Properties @{
        DisplayName = 'Service Bus Namespace - Trusted Microsoft Services AUDIT'
        Description = 'This Azure Policy creates an audit event when the ''Allow trusted Microsoft services to bypass this firewall?'' setting is set to ''Yes''.'
        Version     = '1.0.0'
        Category    = 'Service Bus'
        Mode        = 'All'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.ServiceBus/namespaces/networkRuleSets' {

        Require 'trustedServiceAccessEnabled is not true' {
            Field trustedServiceAccessEnabled | Must -Not -Be 'true' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Service Bus/service-bus-namespace-trusted-microsoft-services-audit/azurepolicy.json in Azure/Community-Policy, under the MIT licence.