Bylaw

Gallery › Cognitive Services › Azure Landing Zones Library

Outbound network access should be restricted for Cognitive Services

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Azure Cognitive Services allow restricting outbound network access. Enable this to limit outbound connectivity for the service.

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

Azure Policy JSONDeny-CognitiveServices-RestrictOutboundNetworkAccess.alz_policy_definition.json · 60 lines
{
  "name": "Deny-CognitiveServices-RestrictOutboundNetworkAccess",
  "properties": {
    "description": "Azure Cognitive Services allow restricting outbound network access. Enable this to limit outbound connectivity for the service.",
    "displayName": "Outbound network access should be restricted for Cognitive Services",
    "metadata": {
      "alzCloudEnvironments": [
        "AzureCloud",
        "AzureChinaCloud",
        "AzureUSGovernment"
      ],
      "category": "Cognitive Services",
      "source": "https://github.com/Azure/Enterprise-Scale/",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny",
        "metadata": {
          "description": "Enable or disable the execution of the policy",
          "displayName": "Effect"
        },
        "type": "String"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "equals": "Microsoft.CognitiveServices/accounts",
            "field": "type"
          },
          {
            "anyOf": [
              {
                "exists": "false",
                "field": "Microsoft.CognitiveServices/accounts/restrictOutboundNetworkAccess"
              },
              {
                "field": "Microsoft.CognitiveServices/accounts/restrictOutboundNetworkAccess",
                "notEquals": true
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "policyType": "Custom"
  },
  "type": "Microsoft.Authorization/policyDefinitions"
}
BylawDeny-CognitiveServices-RestrictOutboundNetworkAccess.bylaw.ps1 · 32 lines
# Converted from Deny-CognitiveServices-RestrictOutboundNetworkAccess.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deny-CognitiveServices-RestrictOutboundNetworkAccess' {

    Properties @{
        DisplayName = 'Outbound network access should be restricted for Cognitive Services'
        Description = 'Azure Cognitive Services allow restricting outbound network access. Enable this to limit outbound connectivity for the service.'
        Category    = 'Cognitive Services'
        Version     = '1.0.0'
        Mode        = 'All'
        Metadata    = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
    }

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

    Resource 'Microsoft.CognitiveServices/accounts' {

        Require 'restrictOutboundNetworkAccess exists' {
            Field restrictOutboundNetworkAccess | Must -Exist
        }

        Require 'restrictOutboundNetworkAccess is true' {
            Field restrictOutboundNetworkAccess | Must -Be $true
        }
    }

    Effect (Param Effect)
}

Source: policy_definitions/Deny-CognitiveServices-RestrictOutboundNetworkAccess.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.