Bylaw

Gallery › Monitoring › Azure built-in policies

Azure Monitor Private Link Scope should use private link

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0

Azure Private Link lets you connect your virtual networks to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to Azure Monitor Private Links Scope, you can reduce data leakage risks. Learn more about private links at: https://docs.microsoft.com/azure/azure-monitor/logs/private-link-security.

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

Azure Policy JSONAzureMonitorPrivateLinkScopes_PrivateEndpoints_AINE.json · 48 lines
{
  "properties": {
    "displayName": "Azure Monitor Private Link Scope should use private link",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Azure Private Link lets you connect your virtual networks to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to Azure Monitor Private Links Scope, you can reduce data leakage risks. Learn more about private links at: https://docs.microsoft.com/azure/azure-monitor/logs/private-link-security.",
    "metadata": {
      "version": "1.0.0",
      "category": "Monitoring"
    },
    "version": "1.0.0",
    "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.Insights/privateLinkScopes"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Insights/privateLinkScopes/privateEndpointConnections",
          "existenceCondition": {
            "field": "Microsoft.Insights/privateLinkScopes/privateEndpointConnections/privateLinkServiceConnectionState.status",
            "equals": "Approved"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/0fc55270-f8bf-4feb-b7b8-5e7e7eacc6a6",
  "name": "0fc55270-f8bf-4feb-b7b8-5e7e7eacc6a6"
}
Bylaw0fc55270-f8bf-4feb-b7b8-5e7e7eacc6a6.bylaw.ps1 · 27 lines
# Converted from AzureMonitorPrivateLinkScopes_PrivateEndpoints_AINE.json by ConvertTo-Bylaw.
Policy '0fc55270-f8bf-4feb-b7b8-5e7e7eacc6a6' {

    Properties @{
        DisplayName   = 'Azure Monitor Private Link Scope should use private link'
        Description   = 'Azure Private Link lets you connect your virtual networks to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to Azure Monitor Private Links Scope, you can reduce data leakage risks. Learn more about private links at: https://docs.microsoft.com/azure/azure-monitor/logs/private-link-security.'
        Version       = '1.0.0'
        Category      = 'Monitoring'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Insights/privateLinkScopes'

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

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