Bylaw

Gallery › Backup › Azure built-in policies

[Preview]: Azure Backup should be enabled for Managed Disks

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0-preview Preview

Ensure protection of your Managed Disks by enabling Azure Backup. Azure Backup is a secure and cost effective data protection solution for Azure.

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

Azure Policy JSONManagedDisks_EnableAzureBackup_Audit.json · 45 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Backup should be enabled for Managed Disks",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Ensure protection of your Managed Disks by enabling Azure Backup. Azure Backup is a secure and cost effective data protection solution for Azure.",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Backup",
      "preview": true
    },
    "version": "1.0.0-preview",
    "parameters": {
      "effect": {
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "type": "String",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ]
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Compute/disks"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.DataProtection/backupInstances"
        }
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/a25a41a7-a769-4271-841d-7ce0297be0c0",
  "name": "a25a41a7-a769-4271-841d-7ce0297be0c0"
}
Bylawa25a41a7-a769-4271-841d-7ce0297be0c0.bylaw.ps1 · 24 lines
# Converted from ManagedDisks_EnableAzureBackup_Audit.json by ConvertTo-Bylaw.
Policy 'a25a41a7-a769-4271-841d-7ce0297be0c0' {

    Properties @{
        DisplayName   = '[Preview]: Azure Backup should be enabled for Managed Disks'
        Description   = 'Ensure protection of your Managed Disks by enabling Azure Backup. Azure Backup is a secure and cost effective data protection solution for Azure.'
        Version       = '1.0.0-preview'
        Category      = 'Backup'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Compute/disks'

    AuditIfNotExists 'Microsoft.DataProtection/backupInstances' -Effect (Param Effect)
}

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