Bylaw

Gallery › App Service › Azure Landing Zones Library

AppService append enable https only setting to enforce https setting.

Converted Policy Append Disabled Mode All Version 1.0.0

Appends the AppService sites object to ensure that HTTPS only is enabled for server/service authentication and protects data in transit from network layer eavesdropping attacks. Please note Append does not enforce compliance use then deny.

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

Azure Policy JSONAppend-AppService-httpsonly.alz_policy_definition.json · 57 lines
{
  "name": "Append-AppService-httpsonly",
  "properties": {
    "description": "Appends the AppService sites object to ensure that  HTTPS only is enabled for  server/service authentication and protects data in transit from network layer eavesdropping attacks. Please note Append does not enforce compliance use then deny.",
    "displayName": "AppService append enable https only setting to enforce https setting.",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "App Service",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Append",
          "Disabled"
        ],
        "defaultValue": "Append",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.Web/sites",
            "field": "type"
          },
          {
            "field": "Microsoft.Web/sites/httpsOnly",
            "notequals": true
          }
        ]
      },
      "then": {
        "details": [
          {
            "field": "Microsoft.Web/sites/httpsOnly",
            "value": true
          }
        ],
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawAppend-AppService-httpsonly.bylaw.ps1 · 30 lines
# Converted from Append-AppService-httpsonly.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Append-AppService-httpsonly' {

    Properties @{
        DisplayName = 'AppService append enable https only setting to enforce https setting.'
        Description = 'Appends the AppService sites object to ensure that  HTTPS only is enabled for  server/service authentication and protects data in transit from network layer eavesdropping attacks. Please note Append does not enforce compliance use then deny.'
        Category    = 'App Service'
        Version     = '1.0.0'
        Mode        = 'All'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

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

    Resource 'Microsoft.Web/sites' {

        Require 'httpsOnly is true' {
            Field httpsOnly | Must -Be $true
        }
    }

    Append -Effect (Param Effect) {
        Field httpsOnly | Add $true
    }
}

Source: policy_definitions/Append-AppService-httpsonly.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.