Gallery › App Service › Azure built-in policies
Configure App Service apps to use the latest TLS version
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.2.0
Periodically, newer versions are released for TLS either due to security flaws, include additional functionality, and enhance speed. Upgrade to the latest TLS version for App Service apps to take advantage of security fixes, if any, and/or new functionalities of the latest version.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONRequireLatestTls_WebApp_DINE.json · 93 lines
{
"properties": {
"displayName": "Configure App Service apps to use the latest TLS version",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Periodically, newer versions are released for TLS either due to security flaws, include additional functionality, and enhance speed. Upgrade to the latest TLS version for App Service apps to take advantage of security fixes, if any, and/or new functionalities of the latest version.",
"metadata": {
"version": "1.2.0",
"category": "App Service"
},
"version": "1.2.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "DeployIfNotExists",
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Web/sites"
},
{
"field": "kind",
"notContains": "functionapp"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Web/sites/config",
"name": "web",
"existenceCondition": {
"field": "Microsoft.Web/sites/config/minTlsVersion",
"greaterOrEquals": "1.2"
},
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/de139f84-1756-47ae-9be6-808fbbe84772"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"siteName": {
"value": "[field('name')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
"type": "string"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/sites/config",
"apiVersion": "2021-02-01",
"name": "[concat(parameters('siteName'), '/web')]",
"properties": {
"minTlsVersion": "1.3"
}
}
],
"outputs": {}
}
}
}
}
}
},
"versions": [
"1.2.0",
"1.1.0",
"1.0.1"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/ae44c1d1-0df2-4ca9-98fa-a3d3ae5b409d",
"name": "ae44c1d1-0df2-4ca9-98fa-a3d3ae5b409d"
}Bylawae44c1d1-0df2-4ca9-98fa-a3d3ae5b409d.bylaw.ps1 · 36 lines
# Converted from RequireLatestTls_WebApp_DINE.json by ConvertTo-Bylaw.
Policy 'ae44c1d1-0df2-4ca9-98fa-a3d3ae5b409d' {
Properties @{
DisplayName = 'Configure App Service apps to use the latest TLS version'
Description = 'Periodically, newer versions are released for TLS either due to security flaws, include additional functionality, and enhance speed. Upgrade to the latest TLS version for App Service apps to take advantage of security fixes, if any, and/or new functionalities of the latest version.'
Version = '1.2.0'
Category = 'App Service'
PolicyVersion = '1.2.0'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Web/sites' {
Require 'kind contains functionapp' {
Field kind | Must -ContainText 'functionapp'
}
}
DeployIfNotExists 'Microsoft.Web/sites/config' -Role 'Website Contributor' -Name 'web' -Effect (Param Effect) {
Require 'minTlsVersion is at least 1.2' {
Field minTlsVersion | Must -BeGreaterOrEqual '1.2' -IfPresent
}
Deployment -TemplateFile './templates/ae44c1d1-0df2-4ca9-98fa-a3d3ae5b409d.json' -Parameters ([ordered]@{
siteName = (Arm '[field(''name'')]')
})
}
}Its deployment templates are written beside it:
templates/ae44c1d1-0df2-4ca9-98fa-a3d3ae5b409d.json
Source: built-in-policies/policyDefinitions/App Service/RequireLatestTls_WebApp_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw