Gallery › SQL › Azure built-in policies
MySQL server should use a virtual network service endpoint
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.2
Virtual network based firewall rules are used to enable traffic from a specific subnet to Azure Database for MySQL while ensuring the traffic stays within the Azure boundary. This policy provides a way to audit if the Azure Database for MySQL has virtual network service endpoint being used.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONMySQL_VirtualNetworkServiceEndpoint_Audit.json · 48 lines
{
"properties": {
"displayName": "MySQL server should use a virtual network service endpoint",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Virtual network based firewall rules are used to enable traffic from a specific subnet to Azure Database for MySQL while ensuring the traffic stays within the Azure boundary. This policy provides a way to audit if the Azure Database for MySQL has virtual network service endpoint being used.",
"metadata": {
"version": "1.0.2",
"category": "SQL"
},
"version": "1.0.2",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.DBforMySQL/servers"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.DBforMySQL/servers/virtualNetworkRules",
"existenceCondition": {
"field": "Microsoft.DBforMySQL/servers/virtualNetworkRules/virtualNetworkSubnetId",
"exists": "true"
}
}
}
},
"versions": [
"1.0.2"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/3375856c-3824-4e0e-ae6a-79e011dd4c47",
"name": "3375856c-3824-4e0e-ae6a-79e011dd4c47"
}Bylaw3375856c-3824-4e0e-ae6a-79e011dd4c47.bylaw.ps1 · 28 lines
# Converted from MySQL_VirtualNetworkServiceEndpoint_Audit.json by ConvertTo-Bylaw.
Policy '3375856c-3824-4e0e-ae6a-79e011dd4c47' {
Properties @{
DisplayName = 'MySQL server should use a virtual network service endpoint'
Description = 'Virtual network based firewall rules are used to enable traffic from a specific subnet to Azure Database for MySQL while ensuring the traffic stays within the Azure boundary. This policy provides a way to audit if the Azure Database for MySQL has virtual network service endpoint being used.'
Version = '1.0.2'
Category = 'SQL'
PolicyVersion = '1.0.2'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.DBforMySQL/servers'
AuditIfNotExists 'Microsoft.DBforMySQL/servers/virtualNetworkRules' -Effect (Param Effect) {
Require 'virtualNetworkSubnetId exists' {
Field virtualNetworkSubnetId | Must -Exist
}
}
}Source: built-in-policies/policyDefinitions/SQL/MySQL_VirtualNetworkServiceEndpoint_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw