Bylaw

Gallery › Mission › Azure built-in policies

Azure SQL Database should restrict or disable Public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. It enforces private-endpoint-only access for Azure SQL databases to remove public ingress paths and reduce exposure risks (see https://learn.microsoft.com/azure/azure-sql/database/connectivity-architecture).

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

Azure Policy JSONSqlDBDisablePublicNetwork.json · 50 lines
{
  "properties": {
    "displayName": "Azure SQL Database should restrict or disable Public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. It enforces private-endpoint-only access for Azure SQL databases to remove public ingress paths and reduce exposure risks (see https://learn.microsoft.com/azure/azure-sql/database/connectivity-architecture).",
    "metadata": {
      "version": "1.0.0",
      "category": "Mission"
    },
    "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.Sql/servers"
          },
          {
            "field": "Microsoft.Sql/servers/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/5cc7aeef-357e-433d-9627-05354b40f8e2",
  "name": "5cc7aeef-357e-433d-9627-05354b40f8e2"
}
Bylaw5cc7aeef-357e-433d-9627-05354b40f8e2.bylaw.ps1 · 28 lines
# Converted from SqlDBDisablePublicNetwork.json by ConvertTo-Bylaw.
Policy '5cc7aeef-357e-433d-9627-05354b40f8e2' {

    Properties @{
        DisplayName   = 'Azure SQL Database should restrict or disable Public network access'
        Description   = 'This policy applies exclusively to Mission Platform products and services; usage outside of these scopes is not supported. It enforces private-endpoint-only access for Azure SQL databases to remove public ingress paths and reduce exposure risks (see https://learn.microsoft.com/azure/azure-sql/database/connectivity-architecture).'
        Version       = '1.0.0'
        Category      = 'Mission'
        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.Sql/servers' {

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

    Effect (Param Effect)
}

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