Bylaw

Gallery › Backup › Azure built-in policies

Azure Recovery Services vaults should use private link for backup

Converted Policy Audit Disabled Mode Indexed Version 2.0.1

Azure Private Link lets you connect your virtual network to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to Azure Recovery Services vaults, data leakage risks are reduced. Learn more about private links at: https://aka.ms/AB-PrivateEndpoints.

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

Azure Policy JSONRecoveryServices_PrivateEndpoint_Audit.json · 68 lines
{
  "properties": {
    "displayName": "Azure Recovery Services vaults should use private link for backup",
    "description": "Azure Private Link lets you connect your virtual network to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to Azure Recovery Services vaults, data leakage risks are reduced. Learn more about private links at: https://aka.ms/AB-PrivateEndpoints.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "2.0.1",
      "category": "Backup"
    },
    "version": "2.0.1",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.RecoveryServices/vaults"
          },
          {
            "count": {
              "field": "Microsoft.RecoveryServices/vaults/privateEndpointConnections[*]",
              "where": {
                "allOf": [
                  {
                    "field": "Microsoft.RecoveryServices/vaults/privateEndpointConnections[*].privateLinkServiceConnectionState.status",
                    "equals": "Approved"
                  },
                  {
                    "field": "Microsoft.RecoveryServices/vaults/privateEndpointConnections[*].provisioningState",
                    "equals": "Succeeded"
                  },
                  {
                    "field": "Microsoft.RecoveryServices/vaults/privateEndpointConnections[*].id",
                    "contains": ".backup"
                  }
                ]
              }
            },
            "less": 1
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "2.0.1",
      "2.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/deeddb44-9f94-4903-9fa0-081d524406e3",
  "name": "deeddb44-9f94-4903-9fa0-081d524406e3"
}
Bylawdeeddb44-9f94-4903-9fa0-081d524406e3.bylaw.ps1 · 32 lines
# Converted from RecoveryServices_PrivateEndpoint_Audit.json by ConvertTo-Bylaw.
Policy 'deeddb44-9f94-4903-9fa0-081d524406e3' {

    Properties @{
        DisplayName   = 'Azure Recovery Services vaults should use private link for backup'
        Description   = 'Azure Private Link lets you connect your virtual network to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to Azure Recovery Services vaults, data leakage risks are reduced. Learn more about private links at: https://aka.ms/AB-PrivateEndpoints.'
        Version       = '2.0.1'
        Category      = 'Backup'
        PolicyVersion = '2.0.1'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.RecoveryServices/vaults' {

        Require 'privateEndpointConnections, privateLinkServiceConnectionState.status, provisioningState and 1 more are as required' {
            Count 'privateEndpointConnections[*]' -Where {
                Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
                Field provisioningState | Must -Be 'Succeeded'
                Field id | Must -ContainText '.backup'
            } | Must -BeGreaterOrEqual 1
        }
    }

    Effect (Param Effect)
}

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