Issue
I want to add my IP to the cosmosdb firewall through the Azure CLI.
The only way to do it with the Azure CLI is with href="https://learn.microsoft.com/en-us/cli/azure/cosmosdb?view=azure-cli-latest#az_cosmosdb_update" rel="nofollow noreferrer">az cosmosdb update
, but it overrides the current IPs in the firewall.
I'm using MacOS so I can get my IP through curl ifconfig.me
.
How can I add my IP to the firewall without overriding the current IPs?
Solution
You can simply GET the list with az cosmosdb list
and append your IP to a list, and cosmosdb update
with that list:
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"
Answered By - sheldonzy Answer Checked By - Mildred Charles (WPSolving Admin)