Bylaw

Gallery › Machine Learning › Azure built-in policies

Configure Azure Machine Learning Workspaces to disable public network access

Converted Policy Disabled Modify Mode Indexed Version 1.0.3

Disable public network access for Azure Machine Learning Workspaces so that your workspaces aren't accessible over the public internet. This helps protect the workspaces against data leakage risks. You can control exposure of your workspaces by creating private endpoints instead. Learn more at: https://learn.microsoft.com/azure/machine-learning/how-to-configure-private-link?view=azureml-api-2&tabs=azure-portal.

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

Azure Policy JSONWorkspace_PublicNetworkAccessDisabled_Modify.json · 63 lines
{
  "properties": {
    "displayName": "Configure Azure Machine Learning Workspaces to disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disable public network access for Azure Machine Learning Workspaces so that your workspaces aren't accessible over the public internet. This helps protect the workspaces against data leakage risks. You can control exposure of your workspaces by creating private endpoints instead. Learn more at: https://learn.microsoft.com/azure/machine-learning/how-to-configure-private-link?view=azureml-api-2&tabs=azure-portal.",
    "metadata": {
      "category": "Machine Learning",
      "version": "1.0.3"
    },
    "version": "1.0.3",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.MachineLearningServices/workspaces"
          },
          {
            "field": "Microsoft.MachineLearningServices/workspaces/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "conflictEffect": "audit",
          "operations": [
            {
              "condition": "[greaterOrEquals(requestContext().apiVersion, '2021-10-01')]",
              "operation": "addOrReplace",
              "field": "Microsoft.MachineLearningServices/workspaces/publicNetworkAccess",
              "value": "Disabled"
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.3"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/a10ee784-7409-4941-b091-663697637c0f",
  "name": "a10ee784-7409-4941-b091-663697637c0f"
}
Bylawa10ee784-7409-4941-b091-663697637c0f.bylaw.ps1 · 30 lines
# Converted from Workspace_PublicNetworkAccessDisabled_Modify.json by ConvertTo-Bylaw.
Policy 'a10ee784-7409-4941-b091-663697637c0f' {

    Properties @{
        DisplayName   = 'Configure Azure Machine Learning Workspaces to disable public network access'
        Description   = 'Disable public network access for Azure Machine Learning Workspaces so that your workspaces aren''t accessible over the public internet. This helps protect the workspaces against data leakage risks. You can control exposure of your workspaces by creating private endpoints instead. Learn more at: https://learn.microsoft.com/azure/machine-learning/how-to-configure-private-link?view=azureml-api-2&tabs=azure-portal.'
        Category      = 'Machine Learning'
        Version       = '1.0.3'
        PolicyVersion = '1.0.3'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.MachineLearningServices/workspaces' {

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

    Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field publicNetworkAccess | AddOrReplace 'Disabled' -Condition (Arm '[greaterOrEquals(requestContext().apiVersion, ''2021-10-01'')]')
    }
}

Source: built-in-policies/policyDefinitions/Machine Learning/Workspace_PublicNetworkAccessDisabled_Modify.json in Azure/azure-policy, under the MIT licence.