Gallery › SQL › Azure built-in policies
Configure Azure SQL Server to disable public network access
Converted Policy Disabled Modify Mode Indexed Version 1.0.0
Disabling the public network access property shuts down public connectivity such that Azure SQL Server can only be accessed from a private endpoint. This configuration disables the public network access for all databases under the Azure SQL Server.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONSqlServer_PublicNetworkAccess_Modify.json · 62 lines
{
"properties": {
"displayName": "Configure Azure SQL Server to disable public network access",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Disabling the public network access property shuts down public connectivity such that Azure SQL Server can only be accessed from a private endpoint. This configuration disables the public network access for all databases under the Azure SQL Server.",
"metadata": {
"category": "SQL",
"version": "1.0.0"
},
"version": "1.0.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.Sql/servers"
},
{
"field": "Microsoft.Sql/servers/publicNetworkAccess",
"notEquals": "Disabled"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"conflictEffect": "audit",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/6d8ee4ec-f05a-4a1d-8b00-a9b17e38b437"
],
"operations": [
{
"operation": "addOrReplace",
"field": "Microsoft.Sql/servers/publicNetworkAccess",
"value": "Disabled"
}
]
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/28b0b1e5-17ba-4963-a7a4-5a1ab4400a0b",
"name": "28b0b1e5-17ba-4963-a7a4-5a1ab4400a0b"
}Bylaw28b0b1e5-17ba-4963-a7a4-5a1ab4400a0b.bylaw.ps1 · 30 lines
# Converted from SqlServer_PublicNetworkAccess_Modify.json by ConvertTo-Bylaw.
Policy '28b0b1e5-17ba-4963-a7a4-5a1ab4400a0b' {
Properties @{
DisplayName = 'Configure Azure SQL Server to disable public network access'
Description = 'Disabling the public network access property shuts down public connectivity such that Azure SQL Server can only be accessed from a private endpoint. This configuration disables the public network access for all databases under the Azure SQL Server.'
Category = 'SQL'
Version = '1.0.0'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Modify', 'Disabled')
Default = 'Modify'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Sql/servers' {
Require 'publicNetworkAccess is Disabled' {
Field publicNetworkAccess | Must -Be 'Disabled'
}
}
Modify -Role 'SQL Server Contributor' -ConflictEffect Audit -Effect (Param Effect) {
Field publicNetworkAccess | AddOrReplace 'Disabled'
}
}Source: built-in-policies/policyDefinitions/SQL/SqlServer_PublicNetworkAccess_Modify.json in Azure/azure-policy, under the MIT licence.
Bylaw