Bylaw

Gallery › Backup › Azure built-in policies

[Preview]: Azure Backup should be enabled on Azure file shares

Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0-preview Preview

Ensure protection of your Azure file shares 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 JSONFileShare_EnableAzureBackup_Audit.json · 53 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Backup should be enabled on Azure file shares",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "Ensure protection of your Azure file shares 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": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts/fileServices/shares"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/fileServices/shares/enabledProtocols",
            "equals": "SMB"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.RecoveryServices/backupprotecteditems"
        }
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/cfc5190a-3b19-4a23-b563-a4c719b666e4",
  "name": "cfc5190a-3b19-4a23-b563-a4c719b666e4"
}
Bylawcfc5190a-3b19-4a23-b563-a4c719b666e4.bylaw.ps1 · 29 lines
# Converted from FileShare_EnableAzureBackup_Audit.json by ConvertTo-Bylaw.
Policy 'cfc5190a-3b19-4a23-b563-a4c719b666e4' {

    Properties @{
        DisplayName   = '[Preview]: Azure Backup should be enabled on Azure file shares'
        Description   = 'Ensure protection of your Azure file shares 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          = 'All'
    }

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

    Resource 'Microsoft.Storage/storageAccounts/fileServices/shares' {

        Require 'enabledProtocols is not SMB' {
            Field enabledProtocols | Must -Not -Be 'SMB' -IfPresent
        }
    }

    AuditIfNotExists 'Microsoft.RecoveryServices/backupprotecteditems' -Effect (Param Effect)
}

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