Gallery › SQL › Azure built-in policies
Public network access should be disabled for MySQL flexible servers
Converted Policy Audit Deny Disabled Mode Indexed Version 2.3.0
Disabling the public network access property improves security by ensuring your Azure Database for MySQL flexible servers 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 JSONMySQL_FlexibleServers_DisablePublicNetworkAccess_Audit.json · 136 lines
{
"properties": {
"displayName": "Public network access should be disabled for MySQL flexible servers",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Disabling the public network access property improves security by ensuring your Azure Database for MySQL flexible servers 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.3.0",
"category": "SQL"
},
"version": "2.3.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.DBforMySQL/flexibleServers"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.delegatedSubnetResourceId",
"exists": "false"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.privateDnsZoneResourceId",
"exists": "false"
},
{
"anyOf": [
{
"allOf": [
{
"field": "Microsoft.DBforMySQL/flexibleServers/createMode",
"equals": "Create"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.publicNetworkAccess",
"notEquals": "Disabled"
}
]
},
{
"allOf": [
{
"field": "Microsoft.DBforMySQL/flexibleServers/createMode",
"equals": "Default"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.publicNetworkAccess",
"notEquals": "Disabled"
}
]
},
{
"allOf": [
{
"field": "Microsoft.DBforMySQL/flexibleServers/createMode",
"equals": "PointInTimeRestore"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.publicNetworkAccess",
"notEquals": "Disabled"
}
]
},
{
"allOf": [
{
"field": "Microsoft.DBforMySQL/flexibleServers/createMode",
"equals": "GeoRestore"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.publicNetworkAccess",
"notEquals": "Disabled"
}
]
},
{
"allOf": [
{
"field": "Microsoft.DBforMySQL/flexibleServers/createMode",
"equals": "Replica"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.publicNetworkAccess",
"notEquals": "Disabled"
}
]
},
{
"allOf": [
{
"field": "Microsoft.DBforMySQL/flexibleServers/createMode",
"notEquals": "Create"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.publicNetworkAccess",
"exists": "true"
},
{
"field": "Microsoft.DBforMySQL/flexibleServers/network.publicNetworkAccess",
"notEquals": "Disabled"
}
]
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"2.3.0",
"2.2.0",
"2.1.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/c9299215-ae47-4f50-9c54-8a392f68a052",
"name": "c9299215-ae47-4f50-9c54-8a392f68a052"
}Bylawc9299215-ae47-4f50-9c54-8a392f68a052.bylaw.ps1 · 73 lines
# Converted from MySQL_FlexibleServers_DisablePublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy 'c9299215-ae47-4f50-9c54-8a392f68a052' {
Properties @{
DisplayName = 'Public network access should be disabled for MySQL flexible servers'
Description = 'Disabling the public network access property improves security by ensuring your Azure Database for MySQL flexible servers 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.3.0'
Category = 'SQL'
PolicyVersion = '2.3.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.DBforMySQL/flexibleServers' {
When {
Field network.delegatedSubnetResourceId | Must -Not -Exist
Field network.privateDnsZoneResourceId | Must -Not -Exist
}
Require 'createMode and network.publicNetworkAccess are as required' {
AnyOf {
Field createMode | Must -Not -Be 'Create' -IfPresent
Field network.publicNetworkAccess | Must -Be 'Disabled'
}
}
Require 'createMode and network.publicNetworkAccess are as required' {
AnyOf {
Field createMode | Must -Not -Be 'Default' -IfPresent
Field network.publicNetworkAccess | Must -Be 'Disabled'
}
}
Require 'createMode and network.publicNetworkAccess are as required' {
AnyOf {
Field createMode | Must -Not -Be 'PointInTimeRestore' -IfPresent
Field network.publicNetworkAccess | Must -Be 'Disabled'
}
}
Require 'createMode and network.publicNetworkAccess are as required' {
AnyOf {
Field createMode | Must -Not -Be 'GeoRestore' -IfPresent
Field network.publicNetworkAccess | Must -Be 'Disabled'
}
}
Require 'createMode and network.publicNetworkAccess are as required' {
AnyOf {
Field createMode | Must -Not -Be 'Replica' -IfPresent
Field network.publicNetworkAccess | Must -Be 'Disabled'
}
}
Require 'createMode and network.publicNetworkAccess are as required' {
AnyOf {
Field createMode | Must -Be 'Create'
Field network.publicNetworkAccess | Must -Not -Exist
Field network.publicNetworkAccess | Must -Be 'Disabled'
}
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/SQL/MySQL_FlexibleServers_DisablePublicNetworkAccess_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw