Bylaw

Gallery › Batch › Azure built-in policies

Public network access should be disabled for Batch accounts

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disabling public network access on a Batch account improves security by ensuring your Batch account can only be accessed from a private endpoint. Learn more about disabling public network access 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 JSONDisablePublicNetworkAccess_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Public network access should be disabled for Batch accounts",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disabling public network access on a Batch account improves security by ensuring your Batch account can only be accessed from a private endpoint. Learn more about disabling public network access at https://docs.microsoft.com/azure/batch/private-connectivity.",
    "metadata": {
      "version": "1.0.0",
      "category": "Batch"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The desired effect of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Batch/batchAccounts"
          },
          {
            "field": "Microsoft.Batch/batchAccounts/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/74c5a0ae-5e48-4738-b093-65e23a060488",
  "name": "74c5a0ae-5e48-4738-b093-65e23a060488"
}
Bylaw74c5a0ae-5e48-4738-b093-65e23a060488.bylaw.ps1 · 29 lines
# Converted from DisablePublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy '74c5a0ae-5e48-4738-b093-65e23a060488' {

    Properties @{
        DisplayName   = 'Public network access should be disabled for Batch accounts'
        Description   = 'Disabling public network access on a Batch account improves security by ensuring your Batch account can only be accessed from a private endpoint. Learn more about disabling public network access at https://docs.microsoft.com/azure/batch/private-connectivity.'
        Version       = '1.0.0'
        Category      = 'Batch'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The desired effect of the policy'
    }

    Resource 'Microsoft.Batch/batchAccounts' {

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

    Effect (Param Effect)
}

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