Bylaw

Gallery › Service Bus › Azure Community Policy

Service Bus Namespace - Tier Setting AUDIT

Converted Policy Audit Disabled Mode All Version 1.0.0

This Azure Policy creates an audit event when the 'Pricing tier' setting is not set to 'Premium'.

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

Azure Policy JSONazurepolicy.json · 48 lines
{
  "name": "60000d6f-a660-4ea2-a347-4ab040f17b6a",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Service Bus Namespace - Tier Setting AUDIT",
    "description": "This Azure Policy creates an audit event when the 'Pricing tier' setting is not set to 'Premium'.",
    "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"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.ServiceBus/namespaces/sku.name",
                "notEquals": "Premium"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw60000d6f-a660-4ea2-a347-4ab040f17b6a.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '60000d6f-a660-4ea2-a347-4ab040f17b6a' {

    Properties @{
        DisplayName = 'Service Bus Namespace - Tier Setting AUDIT'
        Description = 'This Azure Policy creates an audit event when the ''Pricing tier'' setting is not set to ''Premium''.'
        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' {

        Require 'sku.name is Premium' {
            Field sku.name | Must -Be 'Premium'
        }
    }

    Effect (Param Effect)
}

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