Bylaw

Gallery › SQL › Azure built-in policies

Public network access should be disabled for MariaDB servers

Converted Policy Audit Deny Disabled Mode Indexed Version 2.0.0

Disable the public network access property to improve security and ensure your Azure Database for MariaDB can only be accessed from a private endpoint. This configuration strictly disables access from any public address space outside of Azure IP range, and denies all logins that match IP or virtual network-based firewall rules.

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

Azure Policy JSONMariaDB_DisablePublicNetworkAccess_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Public network access should be disabled for MariaDB servers",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disable the public network access property to improve security and ensure your Azure Database for MariaDB can only be accessed from a private endpoint. This configuration strictly disables access from any public address space outside of Azure IP range, and denies all logins that match IP or virtual network-based firewall rules.",
    "metadata": {
      "version": "2.0.0",
      "category": "SQL"
    },
    "version": "2.0.0",
    "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.DBforMariaDB/servers"
          },
          {
            "field": "Microsoft.DBforMariaDB/servers/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "2.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/fdccbe47-f3e3-4213-ad5d-ea459b2fa077",
  "name": "fdccbe47-f3e3-4213-ad5d-ea459b2fa077"
}
Bylawfdccbe47-f3e3-4213-ad5d-ea459b2fa077.bylaw.ps1 · 29 lines
# Converted from MariaDB_DisablePublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy 'fdccbe47-f3e3-4213-ad5d-ea459b2fa077' {

    Properties @{
        DisplayName   = 'Public network access should be disabled for MariaDB servers'
        Description   = 'Disable the public network access property to improve security and ensure your Azure Database for MariaDB can only be accessed from a private endpoint. This configuration strictly disables access from any public address space outside of Azure IP range, and denies all logins that match IP or virtual network-based firewall rules.'
        Version       = '2.0.0'
        Category      = 'SQL'
        PolicyVersion = '2.0.0'
        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.DBforMariaDB/servers' {

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

    Effect (Param Effect)
}

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