Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure Container Apps environments should use private endpoints

Converted Policy Audit Disabled Mode Indexed Version 1.0.0-preview Preview

Azure Private Link lets you connect your virtual networks to Azure services without a public IP address at the source or destination. By mapping private endpoints to Azure Container Apps environments, you can reduce data leakage risks.

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

Azure Policy JSONEnvironmentPrivateEndpoint_Audit.json · 56 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Container Apps environments should use private endpoints",
    "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. By mapping private endpoints to Azure Container Apps environments, you can reduce data leakage risks.",
    "metadata": {
      "version": "1.0.0-preview",
      "preview": true,
      "category": "Sovereignty"
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.App/managedEnvironments"
          },
          {
            "count": {
              "field": "Microsoft.App/managedEnvironments/privateEndpointConnections[*]",
              "where": {
                "field": "Microsoft.App/managedEnvironments/privateEndpointConnections[*].privateLinkServiceConnectionState.status",
                "equals": "Approved"
              }
            },
            "less": 1
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/ec9fea60-a9ec-4efb-8115-3c3c5e061510",
  "name": "ec9fea60-a9ec-4efb-8115-3c3c5e061510"
}
Bylawec9fea60-a9ec-4efb-8115-3c3c5e061510.bylaw.ps1 · 31 lines
# Converted from EnvironmentPrivateEndpoint_Audit.json by ConvertTo-Bylaw.
Policy 'ec9fea60-a9ec-4efb-8115-3c3c5e061510' {

    Properties @{
        DisplayName   = '[Preview]: Azure Container Apps environments should use private endpoints'
        Description   = 'Azure Private Link lets you connect your virtual networks to Azure services without a public IP address at the source or destination. By mapping private endpoints to Azure Container Apps environments, you can reduce data leakage risks.'
        Version       = '1.0.0-preview'
        Preview       = $true
        Category      = 'Sovereignty'
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.App/managedEnvironments' {

        Require 'privateEndpointConnections and privateLinkServiceConnectionState.status are as required' {
            Count 'privateEndpointConnections[*]' -Where {
                Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
            } | Must -BeGreaterOrEqual 1
        }
    }

    Effect (Param Effect)
}

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