Bylaw

Gallery › Azure Arc › Azure built-in policies

Configure Azure Arc Private Link Scopes to disable public network access

Converted Policy Disabled Modify Mode Indexed Version 1.0.0

Disable public network access for your Azure Arc Private Link Scope so that associated Azure Arc resources cannot connect to Azure Arc services over the public internet. This can reduce data leakage risks. Learn more at: https://aka.ms/arc/privatelink.

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

Azure Policy JSONArc_PrivateLinkScope_PublicAccess_Modify.json · 63 lines
{
  "properties": {
    "displayName": "Configure Azure Arc Private Link Scopes to disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disable public network access for your Azure Arc Private Link Scope so that associated Azure Arc resources cannot connect to Azure Arc services over the public internet. This can reduce data leakage risks. Learn more at: https://aka.ms/arc/privatelink.",
    "metadata": {
      "version": "1.0.0",
      "category": "Azure Arc"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.HybridCompute/privateLinkScopes"
          },
          {
            "field": "Microsoft.HybridCompute/privateLinkScopes/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "conflictEffect": "audit",
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/cd570a14-e51a-42ad-bac8-bafd67325302"
          ],
          "operations": [
            {
              "condition": "[greaterOrEquals(requestContext().apiVersion, '2020-08-15-preview')]",
              "operation": "addOrReplace",
              "field": "Microsoft.HybridCompute/privateLinkScopes/publicNetworkAccess",
              "value": "Disabled"
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/de0bc8ea-76e2-4fe2-a288-a07556d0e9c4",
  "name": "de0bc8ea-76e2-4fe2-a288-a07556d0e9c4"
}
Bylawde0bc8ea-76e2-4fe2-a288-a07556d0e9c4.bylaw.ps1 · 30 lines
# Converted from Arc_PrivateLinkScope_PublicAccess_Modify.json by ConvertTo-Bylaw.
Policy 'de0bc8ea-76e2-4fe2-a288-a07556d0e9c4' {

    Properties @{
        DisplayName   = 'Configure Azure Arc Private Link Scopes to disable public network access'
        Description   = 'Disable public network access for your Azure Arc Private Link Scope so that associated Azure Arc resources cannot connect to Azure Arc services over the public internet. This can reduce data leakage risks. Learn more at: https://aka.ms/arc/privatelink.'
        Version       = '1.0.0'
        Category      = 'Azure Arc'
        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.HybridCompute/privateLinkScopes' {

        Require 'publicNetworkAccess is Disabled' {
            Field publicNetworkAccess | Must -Be 'Disabled'
        }
    }

    Modify -Role 'Azure Connected Machine Resource Administrator' -ConflictEffect Audit -Effect (Param Effect) {
        Field publicNetworkAccess | AddOrReplace 'Disabled' -Condition (Arm '[greaterOrEquals(requestContext().apiVersion, ''2020-08-15-preview'')]')
    }
}

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