Bylaw

Gallery › Synapse › Azure built-in policies

Configure Synapse Workspaces to use only Microsoft Entra identities for authentication during workspace creation

Converted Policy Disabled Modify Mode indexed Version 1.2.0

Require and reconfigure Synapse Workspaces 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/Synapse.

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

Azure Policy JSONSynaspeWorkspaceAadOnlyAuthentication_Modify.json · 95 lines
{
  "properties": {
    "displayName": "Configure Synapse Workspaces to use only Microsoft Entra identities for authentication during workspace creation",
    "description": "Require and reconfigure Synapse Workspaces 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/Synapse.",
    "policyType": "BuiltIn",
    "mode": "indexed",
    "metadata": {
      "version": "1.2.0",
      "category": "Synapse"
    },
    "version": "1.2.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Modify",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Synapse/workspaces"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Synapse/workspaces/extraProperties",
                "exists": false
              },
              {
                "value": "[if(empty(field('Microsoft.Synapse/workspaces/extraProperties')), 0, length(intersection(field('Microsoft.Synapse/workspaces/extraProperties'), createObject('WorkspaceType', 'Normal'))))]",
                "equals": 1
              }
            ]
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Synapse/workspaces/azureADOnlyAuthentication",
                "exists": false
              },
              {
                "field": "Microsoft.Synapse/workspaces/azureADOnlyAuthentication",
                "notEquals": true
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Synapse/workspaces/settings",
                    "exists": true
                  },
                  {
                    "value": "[if(empty(field('Microsoft.Synapse/workspaces/settings')), 0, length(intersection(field('Microsoft.Synapse/workspaces/settings'), createObject('azureADOnlyAuthentication', createObject('value', 'true', 'state', 'Inconsistent')))))]",
                    "equals": 1
                  }
                ]
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "conflictEffect": "audit",
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "operations": [
            {
              "operation": "addOrReplace",
              "field": "Microsoft.Synapse/workspaces/azureADOnlyAuthentication",
              "value": true
            }
          ]
        }
      }
    },
    "versions": [
      "1.2.0",
      "1.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/c3624673-d2ff-48e0-b28c-5de1c6767c3c",
  "name": "c3624673-d2ff-48e0-b28c-5de1c6767c3c"
}
Bylawc3624673-d2ff-48e0-b28c-5de1c6767c3c.bylaw.ps1 · 48 lines
# Converted from SynaspeWorkspaceAadOnlyAuthentication_Modify.json by ConvertTo-Bylaw.
Policy 'c3624673-d2ff-48e0-b28c-5de1c6767c3c' {

    Properties @{
        DisplayName   = 'Configure Synapse Workspaces to use only Microsoft Entra identities for authentication during workspace creation'
        Description   = 'Require and reconfigure Synapse Workspaces 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/Synapse.'
        Version       = '1.2.0'
        Category      = 'Synapse'
        PolicyVersion = '1.2.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Synapse/workspaces' {

        When {
            AnyOf {
                Field extraProperties | Must -Not -Exist
                Arm '[if(empty(field(''Microsoft.Synapse/workspaces/extraProperties'')), 0, length(intersection(field(''Microsoft.Synapse/workspaces/extraProperties''), createObject(''WorkspaceType'', ''Normal''))))]' | Must -Be 1
            }
        }

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

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

        Require 'settings is as required' {
            AnyOf {
                Field settings | Must -Not -Exist
                Arm '[if(empty(field(''Microsoft.Synapse/workspaces/settings'')), 0, length(intersection(field(''Microsoft.Synapse/workspaces/settings''), createObject(''azureADOnlyAuthentication'', createObject(''value'', ''true'', ''state'', ''Inconsistent'')))))]' | Must -Not -Be 1
            }
        }
    }

    Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field azureADOnlyAuthentication | AddOrReplace $true
    }
}

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