Bylaw

Gallery › SQL › Azure built-in policies

Azure SQL Managed Instances should have Microsoft Entra-only authentication enabled during creation

Converted Policy Audit Deny Disabled Mode Indexed Version 1.2.0

Require Azure SQL Managed Instance 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 JSONSqlManagedInstance_ADOnlyEnabled_Deny.json · 59 lines
{
  "properties": {
    "displayName": "Azure SQL Managed Instances should have Microsoft Entra-only authentication enabled during creation",
    "description": "Require Azure SQL Managed Instance 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.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "1.2.0",
      "category": "SQL"
    },
    "version": "1.2.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/managedInstances"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Sql/managedInstances/administrators.azureADOnlyAuthentication",
                "exists": false
              },
              {
                "field": "Microsoft.Sql/managedInstances/administrators.azureADOnlyAuthentication",
                "equals": false
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.2.0",
      "1.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/78215662-041e-49ed-a9dd-5385911b3a1f",
  "name": "78215662-041e-49ed-a9dd-5385911b3a1f"
}
Bylaw78215662-041e-49ed-a9dd-5385911b3a1f.bylaw.ps1 · 32 lines
# Converted from SqlManagedInstance_ADOnlyEnabled_Deny.json by ConvertTo-Bylaw.
Policy '78215662-041e-49ed-a9dd-5385911b3a1f' {

    Properties @{
        DisplayName   = 'Azure SQL Managed Instances should have Microsoft Entra-only authentication enabled during creation'
        Description   = 'Require Azure SQL Managed Instance 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.2.0'
        Category      = 'SQL'
        PolicyVersion = '1.2.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/managedInstances' {

        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/SqlManagedInstance_ADOnlyEnabled_Deny.json in Azure/azure-policy, under the MIT licence.