Gallery › SQL › Azure Community Policy
Audit public network access setting for Azure SQL Database
Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0
Customers use public network access property to control public vs private connectivity to Azure SQL Database. This policy audits that public network access property is set to 'Disabled' so that no public connectivity is allowed.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 44 lines
{
"name": "30eae964-155e-430e-a733-07d8d4644568",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Audit public network access setting for Azure SQL Database",
"description": "Customers use public network access property to control public vs private connectivity to Azure SQL Database. This policy audits that public network access property is set to 'Disabled' so that no public connectivity is allowed.",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Sql/servers"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"name": "default",
"type": "Microsoft.Sql/servers",
"existenceCondition": {
"field": "Microsoft.Sql/publicNetworkAccess",
"equals": "Disabled"
}
}
}
}
}
}Bylaw30eae964-155e-430e-a733-07d8d4644568.bylaw.ps1 · 26 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '30eae964-155e-430e-a733-07d8d4644568' {
Properties @{
DisplayName = 'Audit public network access setting for Azure SQL Database'
Description = 'Customers use public network access property to control public vs private connectivity to Azure SQL Database. This policy audits that public network access property is set to ''Disabled'' so that no public connectivity is allowed.'
Version = '1.0.0'
Category = 'SQL'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.Sql/servers'
AuditIfNotExists 'Microsoft.Sql/servers' -Name 'default' -Effect (Param Effect) {
Require 'publicNetworkAccess is Disabled' {
Field 'Microsoft.Sql/publicNetworkAccess' -AllowUnknownAlias | Must -Be 'Disabled'
}
}
}Source: policyDefinitions/SQL/audit-public-network-access-setting-for-azure-sql-database/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw