Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Azure CLI向Cosmosdb数据库防火墙添加IP地址_Azure_Shell_Azure Cosmosdb - Fatal编程技术网

如何通过Azure CLI向Cosmosdb数据库防火墙添加IP地址

如何通过Azure CLI向Cosmosdb数据库防火墙添加IP地址,azure,shell,azure-cosmosdb,Azure,Shell,Azure Cosmosdb,我想通过Azure CLI将我的IP添加到cosmosdb防火墙。 使用Azure CLI的唯一方法是使用,但它会覆盖防火墙中的当前IP 我正在使用MacOS,所以我可以通过curl ifconfig.me获取我的IP 如何在不覆盖当前IP的情况下将我的IP添加到防火墙?您只需获取列表并将您的IP附加到列表中,然后使用该列表进行cosmosdb update: DESIRED_IP=$(curl ifconfig.me) CURRENT_IPS=$(az cosmosdb list | jq -

我想通过Azure CLI将我的IP添加到cosmosdb防火墙。 使用Azure CLI的唯一方法是使用,但它会覆盖防火墙中的当前IP

我正在使用MacOS,所以我可以通过
curl ifconfig.me
获取我的IP


如何在不覆盖当前IP的情况下将我的IP添加到防火墙?

您只需获取列表并将您的IP附加到列表中,然后使用该列表进行
cosmosdb update

DESIRED_IP=$(curl ifconfig.me)
CURRENT_IPS=$(az cosmosdb list | jq -r '.[0].ipRules | .[] | .ipAddressOrRange' | paste -sd "," -)
DESIRED_IPS=$CURRENT_IPS,$DESIRED_IP
az cosmosdb update -n .. -g .. --ip-range-filter "$DESIRED_IPS"