使用 Powershell / Azure CLI 禁用对 Cosmos DB 的数据中心网络访问

Disabling Datacenter Network Access to Cosmos DB Using Powershell / Azure CLI

我浏览了文档以找到一种方法来禁用 "Firewall and Virtual networks" 上的选项 "Accept connections from within public Azure datacenters"使用 Powershell 或 Azure CLI 访问设置页面,但我找不到任何内容。有人能做到吗?

勾选"Accept connections from within public Azure datacenters"这个选项时,一个值为0.0.0.0的条目被设为允许的IP Rannges。这个 0.0.0.0 IP 地址基本上告诉 Cosmos DB 接受来自 public Azure 数据中心的连接。要阻止此访问,您只需从 ipRangeFilter.

中删除 0.0.0.0 ip 地址

要获取属性,您将使用 az cosmos show

az cosmos show --name <cosmosdb-account-name> --resource-group <resource-group-name>`

要更新 ip 范围,您将使用 az cosmos update

az cosmosdb update  --name <cosmosdb-account-name> --resource-group <resource-group-name> --ip-range-filter "104.42.195.92,40.76.54.131,52.176.6.30,52.169.50.45,52.187.184.26"

上述命令将阻止从 public Azure 数据中心访问 cosmos 数据库,但允许从 Azure 门户访问。

Azure PowerShell 中的等效命令是 Get-AzCosmosDBAccount and Update-AzCosmosDBAccount

您可以在此处阅读更多相关信息:https://docs.microsoft.com/en-gb/azure/cosmos-db/how-to-configure-firewall