Bylaw

Gallery › Automation › Azure built-in policies

Automation accounts should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disabling public network access improves security by ensuring that the resource isn't exposed on the public internet. You can limit exposure of your Automation account resources by creating private endpoints instead. Learn more at: https://docs.microsoft.com/azure/automation/how-to/private-link-security.

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

Azure Policy JSONAccount_PublicNetworkAccess_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Automation accounts should disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disabling public network access improves security by ensuring that the resource isn't exposed on the public internet. You can limit exposure of your Automation account resources by creating private endpoints instead. Learn more at: https://docs.microsoft.com/azure/automation/how-to/private-link-security.",
    "metadata": {
      "version": "1.0.0",
      "category": "Automation"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Automation/automationAccounts"
          },
          {
            "field": "Microsoft.Automation/automationAccounts/publicNetworkAccess",
            "notEquals": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/955a914f-bf86-4f0e-acd5-e0766b0efcb6",
  "name": "955a914f-bf86-4f0e-acd5-e0766b0efcb6"
}
Bylaw955a914f-bf86-4f0e-acd5-e0766b0efcb6.bylaw.ps1 · 28 lines
# Converted from Account_PublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy '955a914f-bf86-4f0e-acd5-e0766b0efcb6' {

    Properties @{
        DisplayName   = 'Automation accounts should disable public network access'
        Description   = 'Disabling public network access improves security by ensuring that the resource isn''t exposed on the public internet. You can limit exposure of your Automation account resources by creating private endpoints instead. Learn more at: https://docs.microsoft.com/azure/automation/how-to/private-link-security.'
        Version       = '1.0.0'
        Category      = 'Automation'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Automation/automationAccounts' {

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

    Effect (Param Effect)
}

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