Bylaw

Gallery › App Service › Azure Community Policy

App Service apps should use the latest TLS version for SCM connections

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.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 Function 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 JSONazurepolicy.json · 56 lines
{
  "name": "638423c3-17df-40bc-bf81-9bfa3f5cc0a7",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "App Service apps should use the latest TLS version for SCM connections",
    "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 Function apps to take advantage of security fixes, if any, and/or new functionalities of the latest version.",
    "metadata": {
      "version": "1.0.0",
      "category": "App Service"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "AuditIfNotExists or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites"
          },
          {
            "field": "kind",
            "notContains": "functionapp"
          },
          {
            "field": "kind",
            "notContains": "workflowapp"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Web/sites/config",
          "name": "web",
          "existenceCondition": {
            "field": "Microsoft.Web/sites/config/scmMinTlsVersion",
            "equals": "1.2"
          }
        }
      }
    }
  }
}
Bylaw638423c3-17df-40bc-bf81-9bfa3f5cc0a7.bylaw.ps1 · 35 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '638423c3-17df-40bc-bf81-9bfa3f5cc0a7' {

    Properties @{
        DisplayName = 'App Service apps should use the latest TLS version for SCM connections'
        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 Function apps to take advantage of security fixes, if any, and/or new functionalities of the latest version.'
        Version     = '1.0.0'
        Category    = 'App Service'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.Web/sites' {

        When {
            Field kind | Must -Not -ContainText 'functionapp'
        }

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

    AuditIfNotExists 'Microsoft.Web/sites/config' -Name 'web' -Effect (Param Effect) {
        Require 'scmMinTlsVersion is 1.2' {
            Field scmMinTlsVersion | Must -Be '1.2'
        }
    }
}

Source: policyDefinitions/App Service/app-service-apps-should-use-the-latest-tls-version-for-scm-connections/azurepolicy.json in Azure/Community-Policy, under the MIT licence.