Bylaw

Gallery › App Service › Azure built-in policies

App Service app slots should have local authentication methods disabled for FTP deployments

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.1.0

Disabling local authentication methods for FTP deployments improves security by ensuring that App Service slots exclusively require Microsoft Entra identities for authentication. Learn more at: https://aka.ms/app-service-disable-basic-auth.

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

Azure Policy JSONSlots_FTP_BasicAuthEnabled_AINE.json · 58 lines
{
  "properties": {
    "displayName": "App Service app slots should have local authentication methods disabled for FTP deployments",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disabling local authentication methods for FTP deployments improves security by ensuring that App Service slots exclusively require Microsoft Entra identities for authentication. Learn more at: https://aka.ms/app-service-disable-basic-auth.",
    "metadata": {
      "version": "1.1.0",
      "category": "App Service"
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites/slots"
          },
          {
            "field": "kind",
            "notContains": "functionapp"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "name": "ftp",
          "type": "Microsoft.Web/sites/slots/basicPublishingCredentialsPolicies",
          "existenceCondition": {
            "field": "Microsoft.Web/sites/slots/basicPublishingCredentialsPolicies/allow",
            "equals": "false"
          }
        }
      }
    },
    "versions": [
      "1.1.0",
      "1.0.3"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/ec71c0bc-6a45-4b1f-9587-80dc83e6898c",
  "name": "ec71c0bc-6a45-4b1f-9587-80dc83e6898c"
}
Bylawec71c0bc-6a45-4b1f-9587-80dc83e6898c.bylaw.ps1 · 32 lines
# Converted from Slots_FTP_BasicAuthEnabled_AINE.json by ConvertTo-Bylaw.
Policy 'ec71c0bc-6a45-4b1f-9587-80dc83e6898c' {

    Properties @{
        DisplayName   = 'App Service app slots should have local authentication methods disabled for FTP deployments'
        Description   = 'Disabling local authentication methods for FTP deployments improves security by ensuring that App Service slots exclusively require Microsoft Entra identities for authentication. Learn more at: https://aka.ms/app-service-disable-basic-auth.'
        Version       = '1.1.0'
        Category      = 'App Service'
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('AuditIfNotExists', 'Disabled')
        Default       = 'AuditIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.Web/sites/slots' {

        Require 'kind contains functionapp' {
            Field kind | Must -ContainText 'functionapp'
        }
    }

    AuditIfNotExists 'Microsoft.Web/sites/slots/basicPublishingCredentialsPolicies' -Name 'ftp' -Effect (Param Effect) {
        Require 'allow is false' {
            Field allow | Must -Be 'false'
        }
    }
}

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