Bylaw

Gallery › App Service › Azure Community Policy

Remote Debugging should be disabled for App Service

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0

Remote Debugging should be disabled for App Service

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

Azure Policy JSONazurepolicy.json · 45 lines
{
  "name": "78c92ce1-7e45-4482-95df-1c3b86af1b62",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Remote Debugging should be disabled for App Service",
    "description": "Remote Debugging should be disabled for App Service",
    "metadata": {
      "version": "1.1.0",
      "category": "App Service"
    },
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites"
          },
          {
            "field": "Microsoft.Web/sites/siteConfig.remoteDebuggingEnabled",
            "equals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw78c92ce1-7e45-4482-95df-1c3b86af1b62.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '78c92ce1-7e45-4482-95df-1c3b86af1b62' {

    Properties @{
        DisplayName = 'Remote Debugging should be disabled for App Service'
        Description = 'Remote Debugging should be disabled for App Service'
        Version     = '1.1.0'
        Category    = 'App Service'
        Mode        = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Deny', 'Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Deny, Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.Web/sites' {

        Require 'siteConfig.remoteDebuggingEnabled is not true' {
            Field siteConfig.remoteDebuggingEnabled | Must -Not -Be 'true' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/App Service/remote-debugging-should-be- disbaled-for-app-services/azurepolicy.json in Azure/Community-Policy, under the MIT licence.