David Gard
David Gard

Reputation: 12047

List databases in a CosmosDB instance using the AZ command line

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?

Upvotes: 2

Views: 2167

Answers (2)

jack.chen.job
jack.chen.job

Reputation: 329

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).

Upvotes: 0

andresm53
andresm53

Reputation: 2083

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.

Upvotes: 2

Related Questions