Bylaw

Gallery › Event Grid › Azure built-in policies

Configure Azure Event Grid domains to disable local authentication

Converted Policy Disabled Modify Mode Indexed Version 1.0.0

Disable local authentication methods so that your Azure Event Grid domains exclusively require Azure Active Directory identities for authentication. Learn more at: https://aka.ms/aeg-disablelocalauth.

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

Azure Policy JSONDomains_DisableLocalAuth_Modify.json · 63 lines
{
  "properties": {
    "displayName": "Configure Azure Event Grid domains to disable local authentication",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disable local authentication methods so that your Azure Event Grid domains exclusively require Azure Active Directory identities for authentication. Learn more at: https://aka.ms/aeg-disablelocalauth.",
    "metadata": {
      "version": "1.0.0",
      "category": "Event Grid"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "defaultValue": "Modify",
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.EventGrid/domains"
          },
          {
            "field": "Microsoft.EventGrid/domains/disableLocalAuth",
            "notEquals": true
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "conflictEffect": "audit",
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/1e241071-0855-49ea-94dc-649edcd759de"
          ],
          "operations": [
            {
              "condition": "[greaterOrEquals(requestContext().apiVersion, '2021-06-01-preview')]",
              "operation": "addOrReplace",
              "field": "Microsoft.EventGrid/domains/disableLocalAuth",
              "value": true
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/8ac2748f-3bf1-4c02-a3b6-92ae68cf75b1",
  "name": "8ac2748f-3bf1-4c02-a3b6-92ae68cf75b1"
}
Bylaw8ac2748f-3bf1-4c02-a3b6-92ae68cf75b1.bylaw.ps1 · 30 lines
# Converted from Domains_DisableLocalAuth_Modify.json by ConvertTo-Bylaw.
Policy '8ac2748f-3bf1-4c02-a3b6-92ae68cf75b1' {

    Properties @{
        DisplayName   = 'Configure Azure Event Grid domains to disable local authentication'
        Description   = 'Disable local authentication methods so that your Azure Event Grid domains exclusively require Azure Active Directory identities for authentication. Learn more at: https://aka.ms/aeg-disablelocalauth.'
        Version       = '1.0.0'
        Category      = 'Event Grid'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.EventGrid/domains' {

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

    Modify -Role 'EventGrid Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field disableLocalAuth | AddOrReplace $true -Condition (Arm '[greaterOrEquals(requestContext().apiVersion, ''2021-06-01-preview'')]')
    }
}

Source: built-in-policies/policyDefinitions/Event Grid/Domains_DisableLocalAuth_Modify.json in Azure/azure-policy, under the MIT licence.