Bylaw

Gallery › Web PubSub › Azure built-in policies

[Deprecated]: Azure Web PubSub Service should use private link

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.1-deprecated Deprecated

The policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/eb907f70-7514-460d-92b3-a5ae93b4f917 instead.

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

Azure Policy JSONPrivateEndpointEnabled_Audit_depredated.json · 57 lines
{
  "properties": {
    "displayName": "[Deprecated]: Azure Web PubSub Service should use private link",
    "description": "The policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/eb907f70-7514-460d-92b3-a5ae93b4f917 instead.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "1.0.1-deprecated",
      "category": "Web PubSub",
      "deprecated": true
    },
    "version": "1.0.1",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.SignalRService/webPubSub"
          },
          {
            "count": {
              "field": "Microsoft.SignalRService/webPubSub/privateEndpointConnections[*]",
              "where": {
                "field": "Microsoft.SignalRService/webPubSub/privateEndpointConnections[*].privateLinkServiceConnectionState.status",
                "equals": "Approved"
              }
            },
            "less": 1
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/52630df9-ca7e-442b-853b-c6ce548b31a2",
  "name": "52630df9-ca7e-442b-853b-c6ce548b31a2"
}
Bylaw52630df9-ca7e-442b-853b-c6ce548b31a2.bylaw.ps1 · 32 lines
# Converted from PrivateEndpointEnabled_Audit_depredated.json by ConvertTo-Bylaw.
Policy '52630df9-ca7e-442b-853b-c6ce548b31a2' {

    Properties @{
        DisplayName   = '[Deprecated]: Azure Web PubSub Service should use private link'
        Description   = 'The policy is deprecated. Please use /providers/Microsoft.Authorization/policyDefinitions/eb907f70-7514-460d-92b3-a5ae93b4f917 instead.'
        Version       = '1.0.1-deprecated'
        Category      = 'Web PubSub'
        Deprecated    = $true
        PolicyVersion = '1.0.1'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.SignalRService/webPubSub' {

        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/Web PubSub/PrivateEndpointEnabled_Audit_depredated.json in Azure/azure-policy, under the MIT licence.