Bylaw

Gallery › SQL › Azure built-in policies

Azure SQL logical servers should have Microsoft Entra-only authentication enabled during creation

Converted Policy Audit Deny Disabled Mode Indexed Version 1.3.0

Require Azure SQL logical servers to be created with Microsoft Entra-only authentication. This policy doesn't block local authentication from being re-enabled on resources after create. Consider using the 'Microsoft Entra-only authentication' initiative instead to require both. Learn more at: https://aka.ms/adonlycreate.

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

Azure Policy JSONSqlServer_ADOnlyEnabled_Audit.json · 68 lines
{
  "properties": {
    "displayName": "Azure SQL logical servers should have Microsoft Entra-only authentication enabled during creation",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Require Azure SQL logical servers to be created with Microsoft Entra-only authentication. This policy doesn't block local authentication from being re-enabled on resources after create. Consider using the 'Microsoft Entra-only authentication' initiative instead to require both. Learn more at: https://aka.ms/adonlycreate.",
    "metadata": {
      "version": "1.3.0",
      "category": "SQL"
    },
    "version": "1.3.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.Sql/servers"
          },
          {
            "value": "[resourcegroup().managedBy]",
            "notContains": "/providers/Microsoft.Synapse/"
          },
          {
            "field": "Microsoft.Sql/servers/createMode",
            "notEquals": "Restore"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Sql/servers/administrators.azureADOnlyAuthentication",
                "exists": false
              },
              {
                "field": "Microsoft.Sql/servers/administrators.azureADOnlyAuthentication",
                "equals": false
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.3.0",
      "1.2.0",
      "1.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/abda6d70-9778-44e7-84a8-06713e6db027",
  "name": "abda6d70-9778-44e7-84a8-06713e6db027"
}
Bylawabda6d70-9778-44e7-84a8-06713e6db027.bylaw.ps1 · 37 lines
# Converted from SqlServer_ADOnlyEnabled_Audit.json by ConvertTo-Bylaw.
Policy 'abda6d70-9778-44e7-84a8-06713e6db027' {

    Properties @{
        DisplayName   = 'Azure SQL logical servers should have Microsoft Entra-only authentication enabled during creation'
        Description   = 'Require Azure SQL logical servers to be created with Microsoft Entra-only authentication. This policy doesn''t block local authentication from being re-enabled on resources after create. Consider using the ''Microsoft Entra-only authentication'' initiative instead to require both. Learn more at: https://aka.ms/adonlycreate.'
        Version       = '1.3.0'
        Category      = 'SQL'
        PolicyVersion = '1.3.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Sql/servers' {

        When {
            Arm '[resourcegroup().managedBy]' | Must -Not -ContainText '/providers/Microsoft.Synapse/'
            Field createMode | Must -Not -Be 'Restore'
        }

        Require 'administrators.azureADOnlyAuthentication exists' {
            Field administrators.azureADOnlyAuthentication | Must -Exist
        }

        Require 'administrators.azureADOnlyAuthentication is not false' {
            Field administrators.azureADOnlyAuthentication | Must -Not -Be $false -IfPresent
        }
    }

    Effect (Param Effect)
}

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