Gallery › App Service › Azure built-in policies
Function app slots that use Python should use a specified 'Python version'
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0
Periodically, newer versions are released for Python software either due to security flaws or to include additional functionality. Using the latest Python version for Function apps is recommended in order to take advantage of security fixes, if any, and/or new functionalities of the latest version. This policy only applies to Linux apps. This policy requires you to specify a Python version that meets your requirements.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
{
"properties": {
"displayName": "Function app slots that use Python should use a specified 'Python version'",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Periodically, newer versions are released for Python software either due to security flaws or to include additional functionality. Using the latest Python version for Function apps is recommended in order to take advantage of security fixes, if any, and/or new functionalities of the latest version. This policy only applies to Linux apps. This policy requires you to specify a Python version that meets your requirements.",
"metadata": {
"version": "1.0.0",
"category": "App Service"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
},
"LinuxPythonVersion": {
"type": "String",
"defaultValue": "",
"metadata": {
"displayName": "Linux Python version",
"description": "Specify a supported Python version for Function apps"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Web/sites/slots"
},
{
"field": "kind",
"contains": "functionapp"
},
{
"field": "kind",
"notContains": "workflowapp"
},
{
"field": "kind",
"contains": "linux"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Web/sites/slots/config",
"name": "web",
"existenceCondition": {
"anyOf": [
{
"field": "Microsoft.Web/sites/slots/config/web.linuxFxVersion",
"notContains": "PYTHON"
},
{
"field": "Microsoft.Web/sites/slots/config/web.linuxFxVersion",
"equals": "[concat('PYTHON|', parameters('LinuxPythonVersion'))]"
}
]
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/829b40f3-d3db-4fd2-be46-76663d3aeeb2",
"name": "829b40f3-d3db-4fd2-be46-76663d3aeeb2"
}# Converted from FunctionApp_Slot_Audit_python_Latest.json by ConvertTo-Bylaw.
Policy '829b40f3-d3db-4fd2-be46-76663d3aeeb2' {
Properties @{
DisplayName = 'Function app slots that use Python should use a specified ''Python version'''
Description = 'Periodically, newer versions are released for Python software either due to security flaws or to include additional functionality. Using the latest Python version for Function apps is recommended in order to take advantage of security fixes, if any, and/or new functionalities of the latest version. This policy only applies to Linux apps. This policy requires you to specify a Python version that meets your requirements.'
Version = '1.0.0'
Category = 'App Service'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter LinuxPythonVersion @{
Default = ''
DisplayName = 'Linux Python version'
Description = 'Specify a supported Python version for Function apps'
JsonName = 'LinuxPythonVersion'
}
Resource 'Microsoft.Web/sites/slots' {
When {
Field kind | Must -ContainText 'functionapp'
Field kind | Must -Not -ContainText 'workflowapp'
}
Require 'kind does not contain linux' {
Field kind | Must -Not -ContainText 'linux' -IfPresent
}
}
AuditIfNotExists 'Microsoft.Web/sites/slots/config' -Name 'web' -Effect (Param Effect) {
Require 'web.linuxFxVersion is as required' {
AnyOf {
Field web.linuxFxVersion | Must -Not -ContainText 'PYTHON' -IfPresent
Field web.linuxFxVersion | Must -Be (Arm '[concat(''PYTHON|'', parameters(''LinuxPythonVersion''))]')
}
}
}
}Source: built-in-policies/policyDefinitions/App Service/FunctionApp_Slot_Audit_python_Latest.json in Azure/azure-policy, under the MIT licence.
Bylaw