Bylaw

Gallery › App Service › Azure built-in policies

Function app slots should only be accessible over HTTPS

Converted Policy Audit Deny Disabled Mode Indexed Version 2.1.0

Use of HTTPS ensures server/service authentication and protects data in transit from network layer eavesdropping attacks.

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

Azure Policy JSONFunctionApp_Slot_AuditHTTP_Audit.json · 71 lines
{
  "properties": {
    "displayName": "Function app slots should only be accessible over HTTPS",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Use of HTTPS ensures server/service authentication and protects data in transit from network layer eavesdropping attacks.",
    "metadata": {
      "version": "2.1.0",
      "category": "App Service"
    },
    "version": "2.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled",
          "Deny"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites/slots"
          },
          {
            "field": "kind",
            "contains": "functionapp"
          },
          {
            "field": "kind",
            "notContains": "workflowapp"
          },
          {
            "field": "kind",
            "notContains": "azurecontainerapps"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Web/sites/slots/httpsOnly",
                "exists": "false"
              },
              {
                "field": "Microsoft.Web/sites/slots/httpsOnly",
                "equals": "false"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "2.1.0",
      "2.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/5e5dbe3f-2702-4ffc-8b1e-0cae008a5c71",
  "name": "5e5dbe3f-2702-4ffc-8b1e-0cae008a5c71"
}
Bylaw5e5dbe3f-2702-4ffc-8b1e-0cae008a5c71.bylaw.ps1 · 39 lines
# Converted from FunctionApp_Slot_AuditHTTP_Audit.json by ConvertTo-Bylaw.
Policy '5e5dbe3f-2702-4ffc-8b1e-0cae008a5c71' {

    Properties @{
        DisplayName   = 'Function app slots should only be accessible over HTTPS'
        Description   = 'Use of HTTPS ensures server/service authentication and protects data in transit from network layer eavesdropping attacks.'
        Version       = '2.1.0'
        Category      = 'App Service'
        PolicyVersion = '2.1.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Web/sites/slots' {

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

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

        Require 'httpsOnly is not false' {
            Field httpsOnly | Must -Not -Be 'false' -IfPresent
        }
    }

    Effect (Param Effect)
}

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