Bylaw

Gallery › App Service › Azure built-in policies

App Service app slots should use the latest TLS version

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.2.0

Periodically, newer versions are released for TLS either due to security flaws, include additional functionality, and enhance speed. Upgrade to the latest TLS version for App Service apps to take advantage of security fixes, if any, and/or new functionalities of the latest version.

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

Azure Policy JSONRequireLatestTls_WebApp_Slot_Audit.json · 59 lines
{
  "properties": {
    "displayName": "App Service app slots should use the latest TLS version",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Periodically, newer versions are released for TLS either due to security flaws, include additional functionality, and enhance speed. Upgrade to the latest TLS version for App Service apps to take advantage of security fixes, if any, and/or new functionalities of the latest version.",
    "metadata": {
      "version": "1.2.0",
      "category": "App Service"
    },
    "version": "1.2.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites/slots"
          },
          {
            "field": "kind",
            "notContains": "functionapp"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Web/sites/slots/config",
          "name": "web",
          "existenceCondition": {
            "field": "Microsoft.Web/sites/slots/config/minTlsVersion",
            "greaterOrEquals": "1.2"
          }
        }
      }
    },
    "versions": [
      "1.2.0",
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/4ee5b817-627a-435a-8932-116193268172",
  "name": "4ee5b817-627a-435a-8932-116193268172"
}
Bylaw4ee5b817-627a-435a-8932-116193268172.bylaw.ps1 · 33 lines
# Converted from RequireLatestTls_WebApp_Slot_Audit.json by ConvertTo-Bylaw.
Policy '4ee5b817-627a-435a-8932-116193268172' {

    Properties @{
        DisplayName   = 'App Service app slots should use the latest TLS version'
        Description   = 'Periodically, newer versions are released for TLS either due to security flaws, include additional functionality, and enhance speed. Upgrade to the latest TLS version for App Service apps to take advantage of security fixes, if any, and/or new functionalities of the latest version.'
        Version       = '1.2.0'
        Category      = 'App Service'
        PolicyVersion = '1.2.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.Web/sites/slots' {

        Require 'kind contains functionapp' {
            Field kind | Must -ContainText 'functionapp'
        }
    }

    AuditIfNotExists 'Microsoft.Web/sites/slots/config' -Name 'web' -Effect (Param Effect) {
        Require 'minTlsVersion is at least 1.2' {
            Field minTlsVersion | Must -BeGreaterOrEqual '1.2' -IfPresent
        }
    }
}

Source: built-in-policies/policyDefinitions/App Service/RequireLatestTls_WebApp_Slot_Audit.json in Azure/azure-policy, under the MIT licence.