Bylaw

Gallery › Compute › Azure built-in policies

Protect your data with authentication requirements when exporting or uploading to a disk or snapshot.

Converted Policy Disabled Modify Mode Indexed Version 1.0.0

When export/upload URL is used, the system checks if the user has an identity in Azure Active Directory and has necessary permissions to export/upload the data. Please refer to aka.ms/DisksAzureADAuth.

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

Azure Policy JSONDisks_DataAccessAuthMode_Modify.json · 62 lines
{
  "properties": {
    "displayName": "Protect your data with authentication requirements when exporting or uploading to a disk or snapshot.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "When export/upload URL is used, the system checks if the user has an identity in Azure Active Directory and has necessary permissions to export/upload the data. Please refer to aka.ms/DisksAzureADAuth.",
    "metadata": {
      "version": "1.0.0",
      "category": "Compute"
    },
    "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.Compute/disks"
          },
          {
            "field": "Microsoft.Compute/disks/dataAccessAuthMode",
            "notEquals": "AzureActiveDirectory"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "conflictEffect": "audit",
          "operations": [
            {
              "operation": "addOrReplace",
              "field": "Microsoft.Compute/disks/dataAccessAuthMode",
              "value": "AzureActiveDirectory"
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/c3921d55-b741-4d16-8d56-7f16e99e6892",
  "name": "c3921d55-b741-4d16-8d56-7f16e99e6892"
}
Bylawc3921d55-b741-4d16-8d56-7f16e99e6892.bylaw.ps1 · 30 lines
# Converted from Disks_DataAccessAuthMode_Modify.json by ConvertTo-Bylaw.
Policy 'c3921d55-b741-4d16-8d56-7f16e99e6892' {

    Properties @{
        DisplayName   = 'Protect your data with authentication requirements when exporting or uploading to a disk or snapshot.'
        Description   = 'When export/upload URL is used, the system checks if the user has an identity in Azure Active Directory and has necessary permissions to export/upload the data. Please refer to aka.ms/DisksAzureADAuth.'
        Version       = '1.0.0'
        Category      = 'Compute'
        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.Compute/disks' {

        Require 'dataAccessAuthMode is AzureActiveDirectory' {
            Field dataAccessAuthMode | Must -Be 'AzureActiveDirectory'
        }
    }

    Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field dataAccessAuthMode | AddOrReplace 'AzureActiveDirectory'
    }
}

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