启用公共访问后,可以配置防火墙规则,以允许源自特定 IP 地址或任何 Azure 服务的连接。
使用 Azure 门户:
选择 Azure Database for PostgreSQL 灵活服务器。
在资源菜单中选择“网络”。
如果要删除防火墙规则,请选择类似垃圾桶的图标,该图标位于规则定义右侧。
如果要删除允许源自分配给任何 Azure 服务或资产的任何 IP 地址的连接的防火墙规则,请清除“允许从 Azure 中的任何 Azure 服务对此服务器进行公共访问”复选框。
重要
“允许从 Azure 内的任何 Azure 服务公开访问此服务器”会创建一个防火墙规则,其起始和结束 IP 地址将设置为 0.0.0.0
。 此类规则的存在可将防火墙配置为允许来自分配给任何 Azure 服务或资产的 IP 地址的连接,包括来自其他客户的订阅的连接。
选择“保存”。
一则通知告知你更改正在进行中。
此外,服务器的状态会更改为“正在更新”。
该过程完成后,通知会通知你已应用更改。
此外,服务器的状态会变为“就绪”。
可以通过 az postgres flexible-server firewall-rule delete 命令从服务器中删除防火墙规则。
az postgres flexible-server firewall-rule delete --resource-group <resource_group> --name <server> --rule-name <rule>
如果尝试在未处于 Ready
状态的服务器上删除防火墙规则,你会收到如下错误:
Code: InternalServerError
Message: An unexpected error occured while processing the request. Tracking ID: '<tracking_id>'
备注
防火墙规则名称只能包含 0
-9
、a
-z
、A
-Z
、-
和 _
。 此外,防火墙规则的名称长度必须至少为 3 个字符,且不超过 128 个字符。
如果尝试删除名称无效的防火墙规则,则将收到如下所示的错误:
The firewall rule name can only contain 0-9, a-z, A-Z, '-' and '_'. Additionally, the name of the firewall rule must be at least 3 characters and no more than 128 characters in length.
如果尝试从未启用公共访问权限的服务器移除防火墙规则,则会收到如下所示的错误:
Firewall rule operations cannot be requested for a private access enabled server.