Bylaw

Gallery › App Service › Azure built-in policies

[Deprecated]: API App should only be accessible over HTTPS

Converted Policy Audit Disabled Mode Indexed Version 1.0.0-deprecated Deprecated

Use of HTTPS ensures server/service authentication and protects data in transit from network layer eavesdropping attacks. We recommend all customers who are still using API Apps to implement the built-in policy called 'App Service apps should only be accessible over HTTPS', which is scoped to include API apps in addition to Web Apps.

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

Azure Policy JSONApiApp_AuditHTTP_Audit.json · 54 lines
{
  "properties": {
    "displayName": "[Deprecated]: API App should only be accessible over HTTPS",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Use of HTTPS ensures server/service authentication and protects data in transit from network layer eavesdropping attacks. We recommend all customers who are still using API Apps to implement the built-in policy called 'App Service apps should only be accessible over HTTPS', which is scoped to include API apps in addition to Web Apps.",
    "metadata": {
      "version": "1.0.0-deprecated",
      "category": "App Service",
      "deprecated": true
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Web/sites"
          },
          {
            "field": "kind",
            "like": "*api"
          },
          {
            "field": "Microsoft.Web/sites/httpsOnly",
            "equals": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/b7ddfbdc-1260-477d-91fd-98bd9be789a6",
  "name": "b7ddfbdc-1260-477d-91fd-98bd9be789a6"
}
Bylawb7ddfbdc-1260-477d-91fd-98bd9be789a6.bylaw.ps1 · 34 lines
# Converted from ApiApp_AuditHTTP_Audit.json by ConvertTo-Bylaw.
Policy 'b7ddfbdc-1260-477d-91fd-98bd9be789a6' {

    Properties @{
        DisplayName   = '[Deprecated]: API App should only be accessible over HTTPS'
        Description   = 'Use of HTTPS ensures server/service authentication and protects data in transit from network layer eavesdropping attacks. We recommend all customers who are still using API Apps to implement the built-in policy called ''App Service apps should only be accessible over HTTPS'', which is scoped to include API apps in addition to Web Apps.'
        Version       = '1.0.0-deprecated'
        Category      = 'App Service'
        Deprecated    = $true
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Web/sites' {

        When {
            Field kind | Must -BeLike '*api'
        }

        Require 'httpsOnly is not false' {
            Field httpsOnly | Must -Not -Be 'false' -IfPresent
        }
    }

    Effect (Param Effect)
}

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