Bylaw

Gallery › Batch › Azure built-in policies

Batch accounts should have local authentication methods disabled

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disabling local authentication methods improves security by ensuring that Batch accounts require Azure Active Directory identities exclusively for authentication. Learn more at: https://aka.ms/batch/auth.

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

Azure Policy JSONDisableLocalAuth_Audit.json · 66 lines
{
  "properties": {
    "displayName": "Batch accounts should have local authentication methods disabled",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disabling local authentication methods improves security by ensuring that Batch accounts require Azure Active Directory identities exclusively for authentication. Learn more at: https://aka.ms/batch/auth.",
    "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": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Batch/batchAccounts"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Batch/batchAccounts/allowedAuthenticationModes",
                "exists": "false"
              },
              {
                "count": {
                  "field": "Microsoft.Batch/batchAccounts/allowedAuthenticationModes[*]",
                  "where": {
                    "not": {
                      "field": "Microsoft.Batch/batchAccounts/allowedAuthenticationModes[*]",
                      "equals": "AAD"
                    }
                  }
                },
                "greater": 0
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/6f68b69f-05fe-49cd-b361-777ee9ca7e35",
  "name": "6f68b69f-05fe-49cd-b361-777ee9ca7e35"
}
Bylaw6f68b69f-05fe-49cd-b361-777ee9ca7e35.bylaw.ps1 · 34 lines
# Converted from DisableLocalAuth_Audit.json by ConvertTo-Bylaw.
Policy '6f68b69f-05fe-49cd-b361-777ee9ca7e35' {

    Properties @{
        DisplayName   = 'Batch accounts should have local authentication methods disabled'
        Description   = 'Disabling local authentication methods improves security by ensuring that Batch accounts require Azure Active Directory identities exclusively for authentication. Learn more at: https://aka.ms/batch/auth.'
        Version       = '1.0.0'
        Category      = 'Batch'
        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.Batch/batchAccounts' {

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

        Require 'allowedAuthenticationModes is as required' {
            Each 'allowedAuthenticationModes[*]' {
                Element | Must -Be 'AAD'
            }
        }
    }

    Effect (Param Effect)
}

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