2
votes

I'm attempting to list all Databases from a CosmosDB instances using the AZ command line -

az account set --subscription $subscriptionId
az cosmosdb database list --name $cosmosName --resource-group $resourceGroup

The above command is resulting the following response -

Operation Failed: Resource Not Found

When adding the --debug argument I'm presented with the above error as well as the below detail -

Status code: 404
{"code":"NotFound","message":"Entity with the specified id does not exist in the system.\r\nActivityId: d5383919-7c23-4158-bded-2c623d55ab9b, Microsoft.Azure.Documents.Common/2.0.0.0"}

The CosmosDB that I am attempting to query absolutely does exist, derived by running the command az cosmosdb list, and I copied the SubscriptionId and ResourceGroup directly from the portal.

The MS docs and the command az cosmosdb database list --help both seem to suggest what I'm doing should work.

Can anyone suggest what I could do to fix the issue?

2
What are you providing for --name? That should be the account name (e.g. for yourname.documents.azure.com, you'd specify --name yourname). - David Makogon
I'm specifying the name of the CosmosDB instance, excluding document.azure.com. - David Gard

2 Answers

2
votes

This error can happen if the PC where you are running Azure CLI doesn't have network connectivity to the CosmosDB account. To verify if this is the problem, please go to Portal.Azure.com > CosmosDB account > Firewall and Virtual Networks and if the firewall is enabled, add your current IP address.

0
votes

I had same problem today, and I found firewall is the problem, adding client public IP will fix it, but there is another tricky part, it will take some time even after the firewall rule is updated in Azure portal ( for me I think it's 5~ 10 minutes ). I guess the rule need to be deployed to different location and it take longer time depending on which region you hit.

So you probably just need to be a bit more patient after updated firewall rule.

Also be aware, az allow three different options: (1) resource group name and account name (2) account name and key (3) url-connection and key

I have found only 1 and 3 work, (2) will give me a error: unsupported operand type(s) for +: 'NoneType' and 'str'

both "az cosmosdb database show" and "az cosmosdb database list" have same issue. the version I am using is azure-cli (2.0.45).