Bylaw

Gallery › Cognitive Services › Azure built-in policies

[Deprecated]: Cognitive Services should use private link

Converted Policy Audit Disabled Mode Indexed Version 3.0.1-deprecated Deprecated

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 Cognitive Services, you'll reduce the potential for data leakage. Learn more about private links at: https://go.microsoft.com/fwlink/?linkid=2129800.

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

Azure Policy JSONEnablePrivateEndpoints_Audit.json · 57 lines
{
  "properties": {
    "displayName": "[Deprecated]: Cognitive Services 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 Cognitive Services, you'll reduce the potential for data leakage. Learn more about private links at: https://go.microsoft.com/fwlink/?linkid=2129800.",
    "metadata": {
      "version": "3.0.1-deprecated",
      "category": "Cognitive Services",
      "deprecated": true
    },
    "version": "3.0.1",
    "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.CognitiveServices/accounts"
          },
          {
            "count": {
              "field": "Microsoft.CognitiveServices/accounts/privateEndpointConnections[*]",
              "where": {
                "field": "Microsoft.CognitiveServices/accounts/privateEndpointConnections[*].privateLinkServiceConnectionState.status",
                "equals": "Approved"
              }
            },
            "less": 1
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "3.0.1",
      "3.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/cddd188c-4b82-4c48-a19d-ddf74ee66a01",
  "name": "cddd188c-4b82-4c48-a19d-ddf74ee66a01"
}
Bylawcddd188c-4b82-4c48-a19d-ddf74ee66a01.bylaw.ps1 · 31 lines
# Converted from EnablePrivateEndpoints_Audit.json by ConvertTo-Bylaw.
Policy 'cddd188c-4b82-4c48-a19d-ddf74ee66a01' {

    Properties @{
        DisplayName   = '[Deprecated]: Cognitive Services 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 Cognitive Services, you''ll reduce the potential for data leakage. Learn more about private links at: https://go.microsoft.com/fwlink/?linkid=2129800.'
        Version       = '3.0.1-deprecated'
        Category      = 'Cognitive Services'
        Deprecated    = $true
        PolicyVersion = '3.0.1'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.CognitiveServices/accounts' {

        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/Cognitive Services/EnablePrivateEndpoints_Audit.json in Azure/azure-policy, under the MIT licence.