1). In CLI, you have used az cosmos db list, are you trying to perform firewall change for all Cosmos DBs together? If the number of DBs are more, then it might be slowed.
*Try to apply filter in Command for lesser DBs and see if this improves.
*
I have defined inside teraform some IPs we need to have access into for CosmosDB (just one DB) with 3 Containers. Since every GitHub worker is assigned a different public IP upon execution, we need to include the worker's IP and remove it afterward, leaving the previous ones intact. This is the reason why we are using following command to get a list of configured IPs.
CURRENT_IPS=$(az cosmosdb list | jq -r '.[0].ipRules | .[] | .ipAddressOrRange' | paste -sd "," -)
Then we concatenate with configured CURRENT_IPs + WorkerIP and do update of Firewall policy. After task is finished we are removing WorkerIp.
---2). Please try executing same command from Azure CLI Bash and see if takes same time?
I can confirm that it takes also 8-9 minutes from Azure CLI Bash and 8-9 minutes more to remove IP
Adding IP: 8-9 minutes
az cosmosdb update -n "AzureCosmosDBaccount" -g "ResourceGroup" --ip-range-filter "0.0.0.0,79.XXX.XXX.98"
Removing IP: 8-9 minutes
az cosmosdb update -n "AzureCosmosDBaccount" -g "ResourceGroup" --ip-range-filter "0.0.0.0"