Gallery › App Service › Azure Community Policy
Function apps should have 'Client Certificates (Incoming client certificates)' enabled
Converted Policy AuditIfNotExists DeployIfNotExists Disabled Mode Indexed Version 1.0.1
Client certificates allow for the app to request a certificate for incoming requests. Only clients with valid certificates will be able to reach the app.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 93 lines
{
"name": "91e9e5aa-e63b-4124-ba4e-87e5b43f3820",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Function apps should have 'Client Certificates (Incoming client certificates)' enabled",
"description": "Client certificates allow for the app to request a certificate for incoming requests. Only clients with valid certificates will be able to reach the app.",
"metadata": {
"version": "1.0.1",
"category": "App Service"
},
"mode": "Indexed",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"DeployIfNotExists",
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Web/sites"
},
{
"field": "kind",
"contains": "functionapp"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Web/sites",
"name": "[field('name')]",
"existenceCondition": {
"field": "Microsoft.Web/sites/clientCertEnabled",
"equals": true
},
"evaluationDelay": "AfterProvisioningSuccess",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/de139f84-1756-47ae-9be6-808fbbe84772"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"name": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"location": {
"type": "string"
}
},
"resources": [
{
"name": "[parameters('name')]",
"type": "Microsoft.Web/sites",
"location": "[parameters('location')]",
"apiVersion": "2018-11-01",
"properties": {
"clientCertEnabled": true
}
}
]
}
}
}
}
}
}
}
}Bylaw91e9e5aa-e63b-4124-ba4e-87e5b43f3820.bylaw.ps1 · 35 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '91e9e5aa-e63b-4124-ba4e-87e5b43f3820' {
Properties @{
DisplayName = 'Function apps should have ''Client Certificates (Incoming client certificates)'' enabled'
Description = 'Client certificates allow for the app to request a certificate for incoming requests. Only clients with valid certificates will be able to reach the app.'
Version = '1.0.1'
Category = 'App Service'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'AuditIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'DeployIfNotExists, AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.Web/sites' {
Require 'kind does not contain functionapp' {
Field kind | Must -Not -ContainText 'functionapp' -IfPresent
}
}
DeployIfNotExists 'Microsoft.Web/sites' -Role 'Website Contributor' -Name (Arm '[field(''name'')]') -EvaluationDelay AfterProvisioningSuccess -Effect (Param Effect) {
Require 'clientCertEnabled is true' {
Field clientCertEnabled | Must -Be $true
}
Deployment -TemplateFile './templates/91e9e5aa-e63b-4124-ba4e-87e5b43f3820.json' -Parameters ([ordered]@{
name = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/91e9e5aa-e63b-4124-ba4e-87e5b43f3820.json
Source: policyDefinitions/App Service/function-apps-should-have-incoming-client-certificates-enabled/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw