Bylaw

Gallery › App Service › Azure built-in policies

[Deprecated]: Function app slots should have Client Certificates (Incoming client certificates) enabled

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.2.0-deprecated Deprecated

The policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/f123aa67-1877-4e49-9aa6-33b38fa0bfe4 instead. 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 apps with Http version set to 1.1.

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

Azure Policy JSONClientCert_FunctionApp_Slot_Audit.json · 72 lines
{
  "properties": {
    "displayName": "[Deprecated]: Function app slots should have Client Certificates (Incoming client certificates) enabled",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "The policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/f123aa67-1877-4e49-9aa6-33b38fa0bfe4 instead. 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 apps with Http version set to 1.1.",
    "metadata": {
      "version": "1.2.0-deprecated",
      "category": "App Service",
      "deprecated": true
    },
    "version": "1.2.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "AuditIfNotExists",
          "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')]",
        "details": {
          "type": "Microsoft.Web/sites/slots/config",
          "name": "web",
          "existenceCondition": {
            "field": "Microsoft.Web/sites/slots/config/web.http20Enabled",
            "equals": "true"
          }
        }
      }
    },
    "versions": [
      "1.2.0",
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/153ab4ca-2d58-4b5d-9134-6d8c6bdd321c",
  "name": "153ab4ca-2d58-4b5d-9134-6d8c6bdd321c"
}
Bylaw153ab4ca-2d58-4b5d-9134-6d8c6bdd321c.bylaw.ps1 · 40 lines
# Converted from ClientCert_FunctionApp_Slot_Audit.json by ConvertTo-Bylaw.
Policy '153ab4ca-2d58-4b5d-9134-6d8c6bdd321c' {

    Properties @{
        DisplayName   = '[Deprecated]: Function app slots should have Client Certificates (Incoming client certificates) enabled'
        Description   = 'The policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/f123aa67-1877-4e49-9aa6-33b38fa0bfe4 instead. 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 apps with Http version set to 1.1.'
        Version       = '1.2.0-deprecated'
        Category      = 'App Service'
        Deprecated    = $true
        PolicyVersion = '1.2.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'Disabled'
        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'
        }
    }

    AuditIfNotExists 'Microsoft.Web/sites/slots/config' -Name 'web' -Effect (Param Effect) {
        Require 'web.http20Enabled is true' {
            Field web.http20Enabled | Must -Be 'true'
        }
    }
}

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