Bylaw

Gallery › App Service › Azure built-in policies

Function app slots should have Client Certificates (Incoming client certificates) enabled

Converted Policy Audit Disabled Mode Indexed Version 1.0.0

Client certificates allow for the app to request a certificate for incoming requests. Only clients that have a valid certificate will be able to reach the app. This policy applies to function app slots.

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

Azure Policy JSONClientCert_FunctionApp_Slot_v2_Audit.json · 61 lines
{
  "properties": {
    "displayName": "Function app slots should have Client Certificates (Incoming client certificates) enabled",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Client certificates allow for the app to request a certificate for incoming requests. Only clients that have a valid certificate will be able to reach the app. This policy applies to function app slots.",
    "metadata": {
      "version": "1.0.0",
      "category": "App Service"
    },
    "version": "1.0.0",
    "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/sites/slots"
          },
          {
            "field": "kind",
            "contains": "functionapp"
          },
          {
            "field": "kind",
            "notContains": "workflowapp"
          },
          {
            "field": "kind",
            "notContains": "azurecontainerapps"
          },
          {
            "field": "Microsoft.Web/sites/slots/clientCertEnabled",
            "notEquals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f123aa67-1877-4e49-9aa6-33b38fa0bfe4",
  "name": "f123aa67-1877-4e49-9aa6-33b38fa0bfe4"
}
Bylawf123aa67-1877-4e49-9aa6-33b38fa0bfe4.bylaw.ps1 · 35 lines
# Converted from ClientCert_FunctionApp_Slot_v2_Audit.json by ConvertTo-Bylaw.
Policy 'f123aa67-1877-4e49-9aa6-33b38fa0bfe4' {

    Properties @{
        DisplayName   = 'Function app slots should have Client Certificates (Incoming client certificates) enabled'
        Description   = 'Client certificates allow for the app to request a certificate for incoming requests. Only clients that have a valid certificate will be able to reach the app. This policy applies to function app slots.'
        Version       = '1.0.0'
        Category      = 'App Service'
        PolicyVersion = '1.0.0'
        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/sites/slots' {

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

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

    Effect (Param Effect)
}

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