python sdk getting Status code: 404 connecting to cosmosdb

Rishabh Toshniwal 20 Reputation points

Hi all,

I am getting 404 status code when I am doing any of the operation using CosmosClient.

I have cosmos db (mongo) setup in my subscription. While debugging I could see the "get_database_client"

& "get_container_client" works (as shown in the below screenshot), but all other operations ending with "Status code: 404\nb'', <class 'NoneType'>: None"

Python Packages :



Python Code:

HOST = config.settings['host']
MASTER_KEY = config.settings['master_key']
DATABASE_ID = config.settings['database_id']
CONTAINER_ID = config.settings['container_id']

def run_sample():
    proxy_config = ProxyConfiguration()
    proxy = ""
    if == 'nt' and proxy is not None:
      proxy_config.Host = proxy
    client = cosmos_client1.CosmosClient(HOST, credential=MASTER_KEY, proxy_config = proxy_config, consistency_level = 'Session')
    db = client.get_database_client(DATABASE_ID)
    print ("db link", db.database_link)
    container = db.get_container_client(CONTAINER_ID)
      for i in range(2, 5):
            'id': 'item{0}'.format(i),
            'username': 'rishabht_{0}'.format(i),
            'type': 'bitbucket',
            'token': 'XXXXX'
    except exceptions.CosmosResourceNotFoundError as e:
       x =e  

User's image

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,265 questions
{count} votes

Accepted answer
  1. Sajeetharan 856 Reputation points Microsoft Employee

    Hi Rishabh,

    For opensource APIs such as Mongo API, Cassandra API and Gremlin, we recommend using the opensource drivers. only for the NOSQL API we have our built in SDKs.

    In your case, you can use any of the opensource drivers mentioned here.

    Yes if you are using Python, then you can follow the quick start here,

0 additional answers

Sort by: Most helpful