Bylaw

Gallery › Mission › Azure built-in policies

Storage Account should restrict external private endpoints linking to this tenant.

Converted Policy Audit Deny Disabled Mode All Version 1.1.0

This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. This policy enforces tenant-level network isolation by denying the creation of private endpoints that link storage accounts to external tenants. It helps prevent unintended data exposure and ensures that private connectivity remains within approved boundaries of the organization.

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

Azure Policy JSONStorageRestictExternalPE_Audit.json · 83 lines
{
  "properties": {
    "displayName": "Storage Account should restrict external private endpoints linking to this tenant.",
    "policyType": "BuiltIn",
    "mode": "All",
    "description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. This policy enforces tenant-level network isolation by denying the creation of private endpoints that link storage accounts to external tenants. It helps prevent unintended data exposure and ensures that private connectivity remains within approved boundaries of the organization.",
    "metadata": {
      "version": "1.1.0",
      "category": "Mission"
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Storage Account tenant level isolation by enforcing Private EndPoints effect",
          "description": "Specify Storage Account tenant level isolation by enforcing Private EndPoints effect"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      },
      "excludedSubscriptionIDs": {
        "type": "Array",
        "metadata": {
          "description": "The list of excluded Subscription Ids",
          "displayName": "Excluded Subscription Ids"
        },
        "defaultValue": []
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts/privateEndpointConnections"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/privateEndpointConnections/privateLinkServiceConnectionState.status",
            "equals": "Approved"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Storage/storageAccounts/privateEndpointConnections/privateEndpoint.id",
                "exists": false
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Storage/storageAccounts/privateEndpointConnections/privateEndpoint.id",
                    "exists": true
                  },
                  {
                    "value": "[split(concat(field('Microsoft.Storage/storageAccounts/privateEndpointConnections/privateEndpoint.id'), '//'), '/')[2]]",
                    "notEquals": "[subscription().subscriptionId]"
                  },
                  {
                    "value": "[split(concat(field('Microsoft.Storage/storageAccounts/privateEndpointConnections/privateEndpoint.id'), '//'), '/')[2]]",
                    "notIn": "[parameters('excludedSubscriptionIDs')]"
                  }
                ]
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/ead83ca5-588e-4a27-9d7c-f4df41484dd4",
  "name": "ead83ca5-588e-4a27-9d7c-f4df41484dd4"
}
Bylawead83ca5-588e-4a27-9d7c-f4df41484dd4.bylaw.ps1 · 46 lines
# Converted from StorageRestictExternalPE_Audit.json by ConvertTo-Bylaw.
Policy 'ead83ca5-588e-4a27-9d7c-f4df41484dd4' {

    Properties @{
        DisplayName   = 'Storage Account should restrict external private endpoints linking to this tenant.'
        Description   = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. This policy enforces tenant-level network isolation by denying the creation of private endpoints that link storage accounts to external tenants. It helps prevent unintended data exposure and ensures that private connectivity remains within approved boundaries of the organization.'
        Version       = '1.1.0'
        Category      = 'Mission'
        PolicyVersion = '1.1.0'
        Mode          = 'All'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Storage Account tenant level isolation by enforcing Private EndPoints effect'
        Description   = 'Specify Storage Account tenant level isolation by enforcing Private EndPoints effect'
    }
    Parameter ExcludedSubscriptionIDs @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Excluded Subscription Ids'
        Description = 'The list of excluded Subscription Ids'
    }

    Resource 'Microsoft.Storage/storageAccounts/privateEndpointConnections' {

        When {
            Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
        }

        Require 'privateEndpoint.id exists' {
            Field privateEndpoint.id | Must -Exist
        }

        Require 'privateEndpoint.id is as required' {
            AnyOf {
                Field privateEndpoint.id | Must -Not -Exist
                Arm '[split(concat(field(''Microsoft.Storage/storageAccounts/privateEndpointConnections/privateEndpoint.id''), ''//''), ''/'')[2]]' | Must -Be (Arm '[subscription().subscriptionId]')
                Arm '[split(concat(field(''Microsoft.Storage/storageAccounts/privateEndpointConnections/privateEndpoint.id''), ''//''), ''/'')[2]]' | Must -BeIn (Param ExcludedSubscriptionIDs)
            }
        }
    }

    Effect (Param Effect)
}

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