Bylaw

Gallery › SQL › Azure built-in policies

Azure SQL Managed Instance should have Microsoft Entra-only authentication enabled

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

Require Azure SQL Managed Instance to use Microsoft Entra-only authentication. This policy doesn't block Azure SQL Managed instances from being created with local authentication enabled. It does block local authentication from being 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_DisableADAuth_Deny.json · 58 lines
{
  "properties": {
    "displayName": "Azure SQL Managed Instance should have Microsoft Entra-only authentication enabled",
    "description": "Require Azure SQL Managed Instance to use Microsoft Entra-only authentication. This policy doesn't block Azure SQL Managed instances from being created with local authentication enabled. It does block local authentication from being 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": "All",
    "metadata": {
      "version": "1.0.0",
      "category": "SQL"
    },
    "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.Sql/managedInstances/azureADOnlyAuthentications"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Sql/managedInstances/azureADOnlyAuthentications/azureADOnlyAuthentication",
                "exists": false
              },
              {
                "field": "Microsoft.Sql/managedInstances/azureADOnlyAuthentications/azureADOnlyAuthentication",
                "equals": false
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/0c28c3fb-c244-42d5-a9bf-f35f2999577b",
  "name": "0c28c3fb-c244-42d5-a9bf-f35f2999577b"
}
Bylaw0c28c3fb-c244-42d5-a9bf-f35f2999577b.bylaw.ps1 · 32 lines
# Converted from SqlManagedInstance_ADOnlyEnabled_DisableADAuth_Deny.json by ConvertTo-Bylaw.
Policy '0c28c3fb-c244-42d5-a9bf-f35f2999577b' {

    Properties @{
        DisplayName   = 'Azure SQL Managed Instance should have Microsoft Entra-only authentication enabled'
        Description   = 'Require Azure SQL Managed Instance to use Microsoft Entra-only authentication. This policy doesn''t block Azure SQL Managed instances from being created with local authentication enabled. It does block local authentication from being 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.0.0'
        Category      = 'SQL'
        PolicyVersion = '1.0.0'
        Mode          = 'All'
    }

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

    Resource 'Microsoft.Sql/managedInstances/azureADOnlyAuthentications' {

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

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

    Effect (Param Effect)
}

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