# Get current setting for Public Network Access
az sql server show -n sql-server-name -g sql-server-group --query "publicNetworkAccess"
# Update setting for Public Network Access
az sql server update -n sql-server-name -g sql-server-group --set publicNetworkAccess="Disabled"
拒绝公用网络访问
“公用网络访问”默认设置为“禁用”。 客户可以选择使用公共终结点(使用基于 IP 的服务器级防火墙规则或虚拟网络防火墙规则)或专用终结点(使用 Azure 专用链接)连接到数据库,如网络访问概述中所述。
Error 47073
An instance-specific error occurred while establishing a connection to SQL Server.
The public network interface on this server is not accessible.
To connect to this server, use the Private Endpoint from inside your virtual network.
Error 42101
Unable to create or modify firewall rules when public network interface for the server is disabled.
To manage server or database level firewall rules, please enable the public network interface.
# Get current setting for Minimal TLS Version
az sql server show -n sql-server-name -g sql-server-group --query "minimalTlsVersion"
# Update setting for Minimal TLS Version
az sql server update -n sql-server-name -g sql-server-group --set minimalTlsVersion="1.2"
# Get SQL Server ID
sqlserverid=$(az sql server show -n sql-server-name -g sql-server-group --query 'id' -o tsv)
# Set URI
ids="$sqlserverid/connectionPolicies/Default"
# Get current connection policy
az resource show --ids $ids
# Update connection policy
az resource update --ids $ids --set properties.connectionType=Proxy
Windows 命令提示符中的 Azure CLI
以下 CLI 脚本演示如何从 Windows 命令提示符(安装了 Azure CLI)更改连接策略:
# Get SQL Server ID and set URI
FOR /F "tokens=*" %g IN ('az sql server show --resource-group myResourceGroup-571418053 --name server-538465606 --query "id" -o tsv') do (SET sqlserverid=%g/connectionPolicies/Default)
# Get current connection policy
az resource show --ids %sqlserverid%
# Update connection policy
az resource update --ids %sqlserverid% --set properties.connectionType=Proxy