Bylaw

Gallery › Cognitive Services › Azure built-in policies

[Deprecated]: Cognitive Services accounts should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 3.1.0-deprecated Deprecated

To improve the security of Cognitive Services accounts, ensure that it isn't exposed to the public internet and can only be accessed from a private endpoint. Disable the public network access property as described in https://go.microsoft.com/fwlink/?linkid=2129800. This option disables access from any public address space outside the Azure IP range, and denies all logins that match IP or virtual network-based firewall rules. This reduces data leakage risks.

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

Azure Policy JSONDisablePublicNetworkAccess_Audit.json · 52 lines
{
  "properties": {
    "displayName": "[Deprecated]: Cognitive Services accounts should disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "To improve the security of Cognitive Services accounts, ensure that it isn't exposed to the public internet and can only be accessed from a private endpoint. Disable the public network access property as described in https://go.microsoft.com/fwlink/?linkid=2129800. This option disables access from any public address space outside the Azure IP range, and denies all logins that match IP or virtual network-based firewall rules. This reduces data leakage risks.",
    "metadata": {
      "version": "3.1.0-deprecated",
      "category": "Cognitive Services",
      "deprecated": true
    },
    "version": "3.1.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.CognitiveServices/accounts"
          },
          {
            "field": "Microsoft.CognitiveServices/accounts/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "3.1.0",
      "3.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/0725b4dd-7e76-479c-a735-68e7ee23d5ca",
  "name": "0725b4dd-7e76-479c-a735-68e7ee23d5ca"
}
Bylaw0725b4dd-7e76-479c-a735-68e7ee23d5ca.bylaw.ps1 · 30 lines
# Converted from DisablePublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy '0725b4dd-7e76-479c-a735-68e7ee23d5ca' {

    Properties @{
        DisplayName   = '[Deprecated]: Cognitive Services accounts should disable public network access'
        Description   = 'To improve the security of Cognitive Services accounts, ensure that it isn''t exposed to the public internet and can only be accessed from a private endpoint. Disable the public network access property as described in https://go.microsoft.com/fwlink/?linkid=2129800. This option disables access from any public address space outside the Azure IP range, and denies all logins that match IP or virtual network-based firewall rules. This reduces data leakage risks.'
        Version       = '3.1.0-deprecated'
        Category      = 'Cognitive Services'
        Deprecated    = $true
        PolicyVersion = '3.1.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.CognitiveServices/accounts' {

        Require 'publicNetworkAccess is Disabled' {
            Field publicNetworkAccess | Must -Be 'Disabled'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Cognitive Services/DisablePublicNetworkAccess_Audit.json in Azure/azure-policy, under the MIT licence.