Bylaw

Gallery › App Service › Azure built-in policies

App Service Environment should have internal encryption enabled

Converted Policy Audit Disabled Mode Indexed Version 1.0.1

Setting InternalEncryption to true encrypts the pagefile, worker disks, and internal network traffic between the front ends and workers in an App Service Environment. To learn more, refer to https://docs.microsoft.com/azure/app-service/environment/app-service-app-service-environment-custom-settings#enable-internal-encryption.

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

Azure Policy JSONHostingEnvironment_InternalEncryption_Audit.json · 67 lines
{
  "properties": {
    "displayName": "App Service Environment should have internal encryption enabled",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Setting InternalEncryption to true encrypts the pagefile, worker disks, and internal network traffic between the front ends and workers in an App Service Environment. To learn more, refer to https://docs.microsoft.com/azure/app-service/environment/app-service-app-service-environment-custom-settings#enable-internal-encryption.",
    "metadata": {
      "version": "1.0.1",
      "category": "App Service"
    },
    "version": "1.0.1",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/hostingEnvironments"
          },
          {
            "field": "kind",
            "like": "ASE*"
          },
          {
            "count": {
              "field": "Microsoft.Web/HostingEnvironments/clusterSettings[*]",
              "where": {
                "allOf": [
                  {
                    "field": "Microsoft.Web/HostingEnvironments/clusterSettings[*].name",
                    "equals": "InternalEncryption"
                  },
                  {
                    "field": "Microsoft.Web/HostingEnvironments/clusterSettings[*].value",
                    "equals": "true"
                  }
                ]
              }
            },
            "less": 1
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/fb74e86f-d351-4b8d-b034-93da7391c01f",
  "name": "fb74e86f-d351-4b8d-b034-93da7391c01f"
}
Bylawfb74e86f-d351-4b8d-b034-93da7391c01f.bylaw.ps1 · 36 lines
# Converted from HostingEnvironment_InternalEncryption_Audit.json by ConvertTo-Bylaw.
Policy 'fb74e86f-d351-4b8d-b034-93da7391c01f' {

    Properties @{
        DisplayName   = 'App Service Environment should have internal encryption enabled'
        Description   = 'Setting InternalEncryption to true encrypts the pagefile, worker disks, and internal network traffic between the front ends and workers in an App Service Environment. To learn more, refer to https://docs.microsoft.com/azure/app-service/environment/app-service-app-service-environment-custom-settings#enable-internal-encryption.'
        Version       = '1.0.1'
        Category      = 'App Service'
        PolicyVersion = '1.0.1'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Web/hostingEnvironments' {

        When {
            Field kind | Must -BeLike 'ASE*'
        }

        Require 'clusterSettings, name and value are as required' {
            Count 'clusterSettings[*]' -Where {
                Field name | Must -Be 'InternalEncryption'
                Field value | Must -Be 'true'
            } | Must -BeGreaterOrEqual 1
        }
    }

    Effect (Param Effect)
}

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