Bylaw

Gallery › Network › Azure built-in policies

[Deprecated]: Service Bus should use a virtual network service endpoint

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-deprecated Deprecated

This policy audits any Service Bus not configured to use a virtual network service endpoint. The resource type Microsoft.ServiceBus/namespaces/virtualNetworkRules is deprecated in the latest API version.

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

Azure Policy JSONVirtualNetworkServiceEndpoint_ServiceBus_AINE.json · 49 lines
{
  "properties": {
    "displayName": "[Deprecated]: Service Bus should use a virtual network service endpoint",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy audits any Service Bus not configured to use a virtual network service endpoint. The resource type Microsoft.ServiceBus/namespaces/virtualNetworkRules is deprecated in the latest API version.",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "Network",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.ServiceBus/namespaces"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.ServiceBus/namespaces/virtualNetworkRules",
          "existenceCondition": {
            "field": "Microsoft.ServiceBus/namespaces/virtualNetworkRules/virtualNetworkSubnetId",
            "exists": "true"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/235359c5-7c52-4b82-9055-01c75cf9f60e",
  "name": "235359c5-7c52-4b82-9055-01c75cf9f60e"
}
Bylaw235359c5-7c52-4b82-9055-01c75cf9f60e.bylaw.ps1 · 29 lines
# Converted from VirtualNetworkServiceEndpoint_ServiceBus_AINE.json by ConvertTo-Bylaw.
Policy '235359c5-7c52-4b82-9055-01c75cf9f60e' {

    Properties @{
        DisplayName   = '[Deprecated]: Service Bus should use a virtual network service endpoint'
        Description   = 'This policy audits any Service Bus not configured to use a virtual network service endpoint. The resource type Microsoft.ServiceBus/namespaces/virtualNetworkRules is deprecated in the latest API version.'
        Version       = '1.0.0-deprecated'
        Category      = 'Network'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.ServiceBus/namespaces'

    AuditIfNotExists 'Microsoft.ServiceBus/namespaces/virtualNetworkRules' -Effect (Param Effect) {
        Require 'virtualNetworkSubnetId exists' {
            Field virtualNetworkSubnetId | Must -Exist
        }
    }
}

Source: built-in-policies/policyDefinitions/Network/VirtualNetworkServiceEndpoint_ServiceBus_AINE.json in Azure/azure-policy, under the MIT licence.