Bylaw

Gallery › Mission › Azure built-in policies

App Service Environment should have internal encryption enabled.

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. 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 JSONASERequireEncryption_Audit.json · 68 lines
{
  "properties": {
    "displayName": "App Service Environment should have internal encryption enabled.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. 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.0",
      "category": "Mission"
    },
    "version": "1.0.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/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.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/bfe08d89-8736-48a7-b88e-76fa3f286881",
  "name": "bfe08d89-8736-48a7-b88e-76fa3f286881"
}
Bylawbfe08d89-8736-48a7-b88e-76fa3f286881.bylaw.ps1 · 35 lines
# Converted from ASERequireEncryption_Audit.json by ConvertTo-Bylaw.
Policy 'bfe08d89-8736-48a7-b88e-76fa3f286881' {

    Properties @{
        DisplayName   = 'App Service Environment should have internal encryption enabled.'
        Description   = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. 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.0'
        Category      = 'Mission'
        PolicyVersion = '1.0.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/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/Mission/ASERequireEncryption_Audit.json in Azure/azure-policy, under the MIT licence.