Bylaw

Gallery › Web PubSub › Azure built-in policies

Azure Web PubSub Service should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disabling public network access improves security by ensuring that Azure Web PubSub service isn't exposed on the public internet. Creating private endpoints can limit exposure of Azure Web PubSub service. Learn more at: https://aka.ms/awps/networkacls.

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

Azure Policy JSONPublicNetworkAccessDisabled_AuditDeny.json · 50 lines
{
  "properties": {
    "displayName": "Azure Web PubSub Service should disable public network access",
    "description": "Disabling public network access improves security by ensuring that Azure Web PubSub service isn't exposed on the public internet. Creating private endpoints can limit exposure of Azure Web PubSub service. Learn more at: https://aka.ms/awps/networkacls.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "1.0.0",
      "category": "Web PubSub"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.SignalRService/webPubSub"
          },
          {
            "field": "Microsoft.SignalRService/webPubSub/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/bf45113f-264e-4a87-88f9-29ac8a0aca6a",
  "name": "bf45113f-264e-4a87-88f9-29ac8a0aca6a"
}
Bylawbf45113f-264e-4a87-88f9-29ac8a0aca6a.bylaw.ps1 · 28 lines
# Converted from PublicNetworkAccessDisabled_AuditDeny.json by ConvertTo-Bylaw.
Policy 'bf45113f-264e-4a87-88f9-29ac8a0aca6a' {

    Properties @{
        DisplayName   = 'Azure Web PubSub Service should disable public network access'
        Description   = 'Disabling public network access improves security by ensuring that Azure Web PubSub service isn''t exposed on the public internet. Creating private endpoints can limit exposure of Azure Web PubSub service. Learn more at: https://aka.ms/awps/networkacls.'
        Version       = '1.0.0'
        Category      = 'Web PubSub'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.SignalRService/webPubSub' {

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

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Web PubSub/PublicNetworkAccessDisabled_AuditDeny.json in Azure/azure-policy, under the MIT licence.