Bylaw

Gallery › Network › Azure built-in policies

Azure Service Bus namespaces should be running TLS version 1.2 or newer

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0-preview

Setting the minimum TLS version to 1.2 or newer improves security by ensuring your Azure Service Bus namespace can only be accessed from clients using TLS 1.2 or newer. Using versions of TLS less than 1.2 is not recommended since they have well documented security vulnerabilities.

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

Azure Policy JSONServiceBusNamespaces-TLS_Audit.json · 58 lines
{
  "properties": {
    "displayName": "Azure Service Bus namespaces should be running TLS version 1.2 or newer",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Setting the minimum TLS version to 1.2 or newer improves security by ensuring your Azure Service Bus namespace can only be accessed from clients using TLS 1.2 or newer. Using versions of TLS less than 1.2 is not recommended since they have well documented security vulnerabilities.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Network"
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.ServiceBus/namespaces"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.ServiceBus/namespaces/minimumTlsVersion",
                "exists": "false"
              },
              {
                "field": "Microsoft.ServiceBus/namespaces/minimumTlsVersion",
                "less": "1.2"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/403594a1-5989-4edd-8ea3-cac19a8cc43a",
  "name": "403594a1-5989-4edd-8ea3-cac19a8cc43a"
}
Bylaw403594a1-5989-4edd-8ea3-cac19a8cc43a.bylaw.ps1 · 32 lines
# Converted from ServiceBusNamespaces-TLS_Audit.json by ConvertTo-Bylaw.
Policy '403594a1-5989-4edd-8ea3-cac19a8cc43a' {

    Properties @{
        DisplayName   = 'Azure Service Bus namespaces should be running TLS version 1.2 or newer'
        Description   = 'Setting the minimum TLS version to 1.2 or newer improves security by ensuring your Azure Service Bus namespace can only be accessed from clients using TLS 1.2 or newer. Using versions of TLS less than 1.2 is not recommended since they have well documented security vulnerabilities.'
        Version       = '1.0.0-preview'
        Category      = 'Network'
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.ServiceBus/namespaces' {

        Require 'minimumTlsVersion exists' {
            Field minimumTlsVersion | Must -Exist
        }

        Require 'minimumTlsVersion is at least 1.2' {
            Field minimumTlsVersion | Must -BeGreaterOrEqual '1.2' -IfPresent
        }
    }

    Effect (Param Effect)
}

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