Bylaw

Gallery › Batch › Azure built-in policies

Private endpoint connections on Batch accounts should be enabled

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0

Private endpoint connections allow secure communication by enabling private connectivity to Batch accounts without a need for public IP addresses at the source or destination. Learn more about private endpoints in Batch at https://docs.microsoft.com/azure/batch/private-connectivity.

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

Azure Policy JSONPrivateEndpoints_AINE.json · 48 lines
{
  "properties": {
    "displayName": "Private endpoint connections on Batch accounts should be enabled",
    "description": "Private endpoint connections allow secure communication by enabling private connectivity to Batch accounts without a need for public IP addresses at the source or destination. Learn more about private endpoints in Batch at https://docs.microsoft.com/azure/batch/private-connectivity.",
    "metadata": {
      "version": "1.0.0",
      "category": "Batch"
    },
    "version": "1.0.0",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "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.Batch/batchAccounts"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Batch/batchAccounts/privateEndpointConnections",
          "existenceCondition": {
            "field": "Microsoft.Batch/batchAccounts/privateEndpointConnections/privateLinkServiceConnectionState.status",
            "equals": "Approved"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/009a0c92-f5b4-4776-9b66-4ed2b4775563",
  "name": "009a0c92-f5b4-4776-9b66-4ed2b4775563"
}
Bylaw009a0c92-f5b4-4776-9b66-4ed2b4775563.bylaw.ps1 · 27 lines
# Converted from PrivateEndpoints_AINE.json by ConvertTo-Bylaw.
Policy '009a0c92-f5b4-4776-9b66-4ed2b4775563' {

    Properties @{
        DisplayName   = 'Private endpoint connections on Batch accounts should be enabled'
        Description   = 'Private endpoint connections allow secure communication by enabling private connectivity to Batch accounts without a need for public IP addresses at the source or destination. Learn more about private endpoints in Batch at https://docs.microsoft.com/azure/batch/private-connectivity.'
        Version       = '1.0.0'
        Category      = 'Batch'
        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.Batch/batchAccounts'

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

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