Bylaw

Gallery › SignalR › Azure built-in policies

Modify Azure SignalR Service resources to disable public network access

Converted Policy Disabled Modify Mode Indexed Version 1.2.0

To improve the security of Azure SignalR Service resource, ensure that it isn't exposed to the public internet and can only be accessed from a private endpoint. Disable the public network access property as described in https://aka.ms/asrs/networkacls. This option disables access from any public address space outside the Azure IP range, and denies all logins that match IP or virtual network-based firewall rules. This reduces data leakage risks.

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

Azure Policy JSONPublicNetworkAccessDisabled_Modify.json · 72 lines
{
  "properties": {
    "displayName": "Modify Azure SignalR Service resources to disable public network access",
    "description": "To improve the security of Azure SignalR Service resource, ensure that it isn't exposed to the public internet and can only be accessed from a private endpoint. Disable the public network access property as described in https://aka.ms/asrs/networkacls. This option disables access from any public address space outside the Azure IP range, and denies all logins that match IP or virtual network-based firewall rules. This reduces data leakage risks.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "1.2.0",
      "category": "SignalR"
    },
    "version": "1.2.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.SignalRService/SignalR"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.SignalRService/SignalR/publicNetworkAccess",
                "exists": "false"
              },
              {
                "field": "Microsoft.SignalRService/SignalR/publicNetworkAccess",
                "notEquals": "Disabled"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "conflictEffect": "Audit",
          "roleDefinitionIds": [
            "/providers/Microsoft.Authorization/roleDefinitions/8cf5e20a-e4b2-4e9d-b3a1-5ceb692c2761"
          ],
          "operations": [
            {
              "condition": "[greaterOrEquals(requestContext().apiVersion, '2021-06-01-preview')]",
              "operation": "addOrReplace",
              "field": "Microsoft.SignalRService/SignalR/publicNetworkAccess",
              "value": "Disabled"
            }
          ]
        }
      }
    },
    "versions": [
      "1.2.0",
      "1.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/62a3ae95-8169-403e-a2d2-b82141448092",
  "name": "62a3ae95-8169-403e-a2d2-b82141448092"
}
Bylaw62a3ae95-8169-403e-a2d2-b82141448092.bylaw.ps1 · 34 lines
# Converted from PublicNetworkAccessDisabled_Modify.json by ConvertTo-Bylaw.
Policy '62a3ae95-8169-403e-a2d2-b82141448092' {

    Properties @{
        DisplayName   = 'Modify Azure SignalR Service resources to disable public network access'
        Description   = 'To improve the security of Azure SignalR Service resource, ensure that it isn''t exposed to the public internet and can only be accessed from a private endpoint. Disable the public network access property as described in https://aka.ms/asrs/networkacls. This option disables access from any public address space outside the Azure IP range, and denies all logins that match IP or virtual network-based firewall rules. This reduces data leakage risks.'
        Version       = '1.2.0'
        Category      = 'SignalR'
        PolicyVersion = '1.2.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.SignalRService/SignalR' {

        Require 'publicNetworkAccess exists' {
            Field publicNetworkAccess | Must -Exist
        }

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

    Modify -Role 'SignalR/Web PubSub Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field publicNetworkAccess | AddOrReplace 'Disabled' -Condition (Arm '[greaterOrEquals(requestContext().apiVersion, ''2021-06-01-preview'')]')
    }
}

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