Gallery › App Service › Azure Community Policy
Enforce FTPS only or disablement of FTP/FTPS for App Service and Azure Functions
Converted Policy AuditIfNotExists DeployIfNotExists Disabled Mode Indexed Version 1.0.0
Enforce FTPS only or disablement of FTP/FTPS for App Service and Azure Functions
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 106 lines
{
"name": "dd3e395e-1e91-4021-9903-4f2f47229c2a",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Enforce FTPS only or disablement of FTP/FTPS for App Service and Azure Functions",
"description": "Enforce FTPS only or disablement of FTP/FTPS for App Service and Azure Functions",
"metadata": {
"version": "1.0.0",
"category": "App Service"
},
"mode": "Indexed",
"parameters": {
"allowFTPS": {
"type": "boolean",
"defaultValue": false,
"metadata": {
"displayName": "Allow FTPS",
"description": "Allow FtpsOnly as a valid configuration. FTP will still be disabled."
}
},
"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/config",
"name": "web",
"existenceCondition": {
"field": "Microsoft.Web/sites/config/ftpsState",
"in": "[if(parameters('allowFTPS'), createArray('FtpsOnly', 'Disabled'), createArray('Disabled'))]"
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/de139f84-1756-47ae-9be6-808fbbe84772"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"name": {
"value": "[field('name')]"
},
"allowFTPS": {
"value": "[parameters('allowFTPS')]"
},
"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"
},
"allowFTPS": {
"type": "bool"
},
"location": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('name'), '/web')]",
"type": "Microsoft.Web/sites/config",
"location": "[parameters('location')]",
"apiVersion": "2018-11-01",
"properties": {
"ftpsState": "[if(parameters('allowFTPS'), 'FtpsOnly', 'Disabled')]"
}
}
]
}
}
}
}
}
}
}
}Bylawdd3e395e-1e91-4021-9903-4f2f47229c2a.bylaw.ps1 · 42 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'dd3e395e-1e91-4021-9903-4f2f47229c2a' {
Properties @{
DisplayName = 'Enforce FTPS only or disablement of FTP/FTPS for App Service and Azure Functions'
Description = 'Enforce FTPS only or disablement of FTP/FTPS for App Service and Azure Functions'
Version = '1.0.0'
Category = 'App Service'
Mode = 'Indexed'
}
Parameter AllowFTPS @{
Type = 'boolean'
Default = $false
DisplayName = 'Allow FTPS'
Description = 'Allow FtpsOnly as a valid configuration. FTP will still be disabled.'
}
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/config' -Role 'Website Contributor' -Name 'web' -Effect (Param Effect) {
Require 'ftpsState is as required' {
Field ftpsState | Must -BeIn (Arm '[if(parameters(''allowFTPS''), createArray(''FtpsOnly'', ''Disabled''), createArray(''Disabled''))]')
}
Deployment -TemplateFile './templates/dd3e395e-1e91-4021-9903-4f2f47229c2a.json' -Parameters ([ordered]@{
name = (Arm '[field(''name'')]')
allowFTPS = (Param AllowFTPS)
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/dd3e395e-1e91-4021-9903-4f2f47229c2a.json
Source: policyDefinitions/App Service/enforce-ftps-only-or-disablement-of-ftp-ftps-for-app-service-and-azure-functions/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw