Bylaw

Gallery › App Service › Azure built-in policies

Function apps should enable end to end encryption

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0

Enabling end to end encryption ensures front-end intra-cluster traffic between App Service front-ends and the workers running application workloads is encrypted.

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

Azure Policy JSONFunctionApp_EndToEndEncryption_Audit.json · 71 lines
{
  "properties": {
    "displayName": "Function apps should enable end to end encryption",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Enabling end to end encryption ensures front-end intra-cluster traffic between App Service front-ends and the workers running application workloads is encrypted.",
    "metadata": {
      "version": "1.1.0",
      "category": "App Service"
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites"
          },
          {
            "field": "kind",
            "contains": "functionapp"
          },
          {
            "field": "kind",
            "notContains": "workflowapp"
          },
          {
            "field": "kind",
            "notContains": "azurecontainerapps"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Web/sites/endToEndEncryptionEnabled",
                "exists": "false"
              },
              {
                "field": "Microsoft.Web/sites/endToEndEncryptionEnabled",
                "notEquals": "true"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/387140f1-6da9-4741-bcee-3b5edcdfd9ec",
  "name": "387140f1-6da9-4741-bcee-3b5edcdfd9ec"
}
Bylaw387140f1-6da9-4741-bcee-3b5edcdfd9ec.bylaw.ps1 · 38 lines
# Converted from FunctionApp_EndToEndEncryption_Audit.json by ConvertTo-Bylaw.
Policy '387140f1-6da9-4741-bcee-3b5edcdfd9ec' {

    Properties @{
        DisplayName   = 'Function apps should enable end to end encryption'
        Description   = 'Enabling end to end encryption ensures front-end intra-cluster traffic between App Service front-ends and the workers running application workloads is encrypted.'
        Version       = '1.1.0'
        Category      = 'App Service'
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Web/sites' {

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

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

        Require 'endToEndEncryptionEnabled is true' {
            Field endToEndEncryptionEnabled | Must -Be 'true'
        }
    }

    Effect (Param Effect)
}

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