Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure Application Gateway should use private link

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-preview Preview

Azure Application Gateway instances should have at least one approved private endpoint connection. Clients in a virtual network can securely access resources that have private endpoint connections through private links.

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

Azure Policy JSONApplicationGateway_PrivateEndpoint_AINE.json · 49 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Application Gateway should use private link",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Azure Application Gateway instances should have at least one approved private endpoint connection. Clients in a virtual network can securely access resources that have private endpoint connections through private links.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Sovereignty",
      "preview": true
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Network/applicationGateways"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Network/applicationGateways/privateEndpointConnections",
          "existenceCondition": {
            "field": "Microsoft.Network/applicationGateways/privateEndpointConnections/privateLinkServiceConnectionState.status",
            "equals": "Approved"
          }
        }
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/5204629f-8140-4a58-90a7-de4e04957a97",
  "name": "5204629f-8140-4a58-90a7-de4e04957a97"
}
Bylaw5204629f-8140-4a58-90a7-de4e04957a97.bylaw.ps1 · 28 lines
# Converted from ApplicationGateway_PrivateEndpoint_AINE.json by ConvertTo-Bylaw.
Policy '5204629f-8140-4a58-90a7-de4e04957a97' {

    Properties @{
        DisplayName   = '[Preview]: Azure Application Gateway should use private link'
        Description   = 'Azure Application Gateway instances should have at least one approved private endpoint connection. Clients in a virtual network can securely access resources that have private endpoint connections through private links.'
        Version       = '1.0.0-preview'
        Category      = 'Sovereignty'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Network/applicationGateways'

    AuditIfNotExists 'Microsoft.Network/applicationGateways/privateEndpointConnections' -Effect (Param Effect) {
        Require 'privateLinkServiceConnectionState.status is Approved' {
            Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
        }
    }
}

Source: built-in-policies/policyDefinitions/Sovereignty/ApplicationGateway_PrivateEndpoint_AINE.json in Azure/azure-policy, under the MIT licence.