Bylaw

Gallery › SignalR › Azure built-in policies

Azure SignalR Service should use private link

Converted Policy Audit Disabled Mode Indexed Version 1.0.0

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 your Azure SignalR Service resource instead of the entire service, you'll reduce your data leakage risks. Learn more about private links at: https://aka.ms/asrs/privatelink.

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

Azure Policy JSONPrivateEndpointEnabled_Audit_v2.json · 55 lines
{
  "properties": {
    "displayName": "Azure SignalR Service should use private link",
    "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 your Azure SignalR Service resource instead of the entire service, you'll reduce your data leakage risks. Learn more about private links at: https://aka.ms/asrs/privatelink.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "1.0.0",
      "category": "SignalR"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.SignalRService/SignalR"
          },
          {
            "count": {
              "field": "Microsoft.SignalRService/SignalR/privateEndpointConnections[*]",
              "where": {
                "field": "Microsoft.SignalRService/SignalR/privateEndpointConnections[*].privateLinkServiceConnectionState.status",
                "equals": "Approved"
              }
            },
            "less": 1
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/2393d2cf-a342-44cd-a2e2-fe0188fd1234",
  "name": "2393d2cf-a342-44cd-a2e2-fe0188fd1234"
}
Bylaw2393d2cf-a342-44cd-a2e2-fe0188fd1234.bylaw.ps1 · 31 lines
# Converted from PrivateEndpointEnabled_Audit_v2.json by ConvertTo-Bylaw.
Policy '2393d2cf-a342-44cd-a2e2-fe0188fd1234' {

    Properties @{
        DisplayName   = 'Azure SignalR Service should use private link'
        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 your Azure SignalR Service resource instead of the entire service, you''ll reduce your data leakage risks. Learn more about private links at: https://aka.ms/asrs/privatelink.'
        Version       = '1.0.0'
        Category      = 'SignalR'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.SignalRService/SignalR' {

        Require 'privateEndpointConnections and privateLinkServiceConnectionState.status are as required' {
            Count 'privateEndpointConnections[*]' -Where {
                Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
            } | Must -BeGreaterOrEqual 1
        }
    }

    Effect (Param Effect)
}

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