Bylaw

Gallery › SQL › Azure Community Policy

Audit Allow Azure services and resources to access this server

Converted Policy Audit Disabled Mode All Version 1.0.0 Preview

This option configures the firewall to allow connections from IP addresses allocated to any Azure service or asset, including connections from the subscriptions of other customers. Rather than allowing any service in any tenant to access this server, network access should be limited using the virtual network option or private access.

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

Azure Policy JSONazurepolicy.json · 45 lines
{
  "name": "e369a998-a653-4e19-a058-a6256c3f999b",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": { 
    "displayName": "Audit Allow Azure services and resources to access this server",
    "description": "This option configures the firewall to allow connections from IP addresses allocated to any Azure service or asset, including connections from the subscriptions of other customers. Rather than allowing any service in any tenant to access this server, network access should be limited using the virtual network option or private access.",
    "metadata": {
      "category": "SQL",
      "version": "1.0.0",
      "preview": true
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Sql/servers/firewallrules"
          },
          {
            "field": "name",
            "like": "AllowAllWindowsAzureIps"
          }
        ]
      },  
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawe369a998-a653-4e19-a058-a6256c3f999b.bylaw.ps1 · 28 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'e369a998-a653-4e19-a058-a6256c3f999b' {

    Properties @{
        DisplayName = 'Audit Allow Azure services and resources to access this server'
        Description = 'This option configures the firewall to allow connections from IP addresses allocated to any Azure service or asset, including connections from the subscriptions of other customers. Rather than allowing any service in any tenant to access this server, network access should be limited using the virtual network option or private access.'
        Category    = 'SQL'
        Version     = '1.0.0'
        Preview     = $true
        Mode        = 'All'
    }

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

    Resource 'Microsoft.Sql/servers/firewallrules' {

        Require 'name is not like AllowAllWindowsAzureIps' {
            Field name | Must -Not -BeLike 'AllowAllWindowsAzureIps' -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/SQL/audit-allow-azure-services-and-resources-to-access-this-server/azurepolicy.json in Azure/Community-Policy, under the MIT licence.