Bylaw

Gallery › Network › Azure Community Policy

deny-app-gateways-cant-have-private-listener

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

need to add description

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

Azure Policy JSONazurepolicy.json · 51 lines
{
  "name": "661c9658-3220-4a5f-976c-f65c1a8fd827",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "deny-app-gateways-cant-have-private-listener",
    "description": "need to add description",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "mode": "All",
    "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.Network/applicationGateways"
          },
          {
            "count": {
              "field": "Microsoft.Network/applicationGateways/frontendIPConfigurations[*]",
              "where": {
                "field": "Microsoft.Network/applicationGateways/frontendIPConfigurations[*].subnet.id",
                "like": "*"
              }
            },
            "greater": 0
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw661c9658-3220-4a5f-976c-f65c1a8fd827.bylaw.ps1 · 29 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '661c9658-3220-4a5f-976c-f65c1a8fd827' {

    Properties @{
        DisplayName = 'deny-app-gateways-cant-have-private-listener'
        Description = 'need to add description'
        Version     = '1.0.0'
        Category    = 'Network'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.Network/applicationGateways' {

        Require 'frontendIPConfigurations and subnet.id are as required' {
            Each 'frontendIPConfigurations[*]' {
                Field subnet.id | Must -Not -BeLike '*'
            }
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Network/deny-app-gateways-cant-have-private-listener/azurepolicy.json in Azure/Community-Policy, under the MIT licence.